Content deleted Content added
Mike Dillon (talk | contribs) m skip nulls passed to easyDOM functions |
Mike Dillon (talk | contribs) m make this stuff work with booleans and numbers as children and attribute values |
||
Line 2:
function createEasyDomFunction(name) {
var boolType = typeof true;
var stringType = typeof '';
var numberType = typeof 0;
var functionType = typeof function() {};
Line 46 ⟶ 48:
if (attrValue == null) {
return;
}
// Stringify non-string values
if (typeof attrValue != stringValue) {
attrValue = attrValue.toString();
}
Line 62 ⟶ 69:
}
// Detect
if (firstArgType == stringType) {▼
return 0;
}
// Detect
if (firstArgType == boolType ||
firstArgType == numberType ||
firstArgType == functionType) {
return 0;
}
// Detect DOM nodes as first argument
if (typeof args[0].nodeType != 'undefined') {
return 0;
Line 101 ⟶ 111:
continue;
}
if (typeof child.nodeType ==
child = document.createTextNode(child.toString());
}
elem.appendChild(child);
|