fix el.attributes is not an array error

pull/272/head
nightwing 2016-03-15 17:23:21 +04:00
rodzic 53c2e7ec7d
commit 9ac6556d5a
2 zmienionych plików z 8 dodań i 54 usunięć

Wyświetl plik

@ -245,38 +245,15 @@ define(function(require, module, exports) {
dropdown.setAttribute("value", item.value); dropdown.setAttribute("value", item.value);
break; break;
default: default:
// Attributes we are happy to set directly // supported attributes
var validAttributes = [ var validAttributes = /^(value|visible|zindex|disabled|caption|tooltip|command|class|icon|src|submenu)$/;
"value",
"visible",
"zindex",
"disabled",
"caption",
"tooltip",
"command",
"class",
"icon",
"src",
"submenu"
];
Object.keys(item).forEach(function(key) { Object.keys(item).forEach(function(key) {
// Check for onclick explictly // Check for onclick explictly
if (key === "onclick") if (key === "onclick")
return el.onclick = item.onclick; return el.onclick = item.onclick;
// Check for attributes we know exist and will directly set // Check for attributes we know exist and will directly set
if (validAttributes.indexOf(key) > -1) if (validAttributes.test(key))
return el.setAttribute(key, item[key]); return el.setAttribute(key, item[key]);
// Otherwise, check if the object has the attribute to set
if (el.attributes) {
var attributeExists = el.attributes.some(function(attribute) {
return (attribute.name === key);
});
if (attributeExists)
el.setAttribute(key, item[key]);
}
}); });
break; break;
} }

Wyświetl plik

@ -481,38 +481,15 @@ define(function(require, exports, module) {
} }
break; break;
default: default:
// Attributes we are happy to set directly // supported attributes
var validAttributes = [ var validAttributes = /^(value|visible|zindex|disabled|caption|tooltip|command|class|icon|src|submenu)$/;
"value",
"visible",
"zindex",
"disabled",
"caption",
"tooltip",
"command",
"class",
"icon",
"src",
"submenu"
];
Object.keys(item).forEach(function(key) { Object.keys(item).forEach(function(key) {
// Check for onclick explictly // Check for onclick explictly
if (key === "onclick") if (key === "onclick")
return el.lastChild.onclick = item.onclick; return el.onclick = item.onclick;
// Check for attributes we know exist and will directly set // Check for attributes we know exist and will directly set
if (validAttributes.indexOf(key) > -1) if (validAttributes.test(key))
return el.lastChild.setAttribute(key, item[key]); return el.setAttribute(key, item[key]);
// Otherwise, check if the object has the attribute to set
if (el.lastChild && el.lastChild.attributes) {
var attributeExists = el.lastChild.attributes.some(function(attribute) {
return (attribute.name === key);
});
if (attributeExists)
el.lastChild.setAttribute(key, item[key]);
}
}); });
break; break;
} }