kopia lustrzana https://github.com/c9/core
fix el.attributes is not an array error
rodzic
53c2e7ec7d
commit
9ac6556d5a
|
@ -245,38 +245,15 @@ define(function(require, module, exports) {
|
|||
dropdown.setAttribute("value", item.value);
|
||||
break;
|
||||
default:
|
||||
// Attributes we are happy to set directly
|
||||
var validAttributes = [
|
||||
"value",
|
||||
"visible",
|
||||
"zindex",
|
||||
"disabled",
|
||||
"caption",
|
||||
"tooltip",
|
||||
"command",
|
||||
"class",
|
||||
"icon",
|
||||
"src",
|
||||
"submenu"
|
||||
];
|
||||
|
||||
// supported attributes
|
||||
var validAttributes = /^(value|visible|zindex|disabled|caption|tooltip|command|class|icon|src|submenu)$/;
|
||||
Object.keys(item).forEach(function(key) {
|
||||
// Check for onclick explictly
|
||||
if (key === "onclick")
|
||||
return el.onclick = item.onclick;
|
||||
|
||||
// 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]);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -481,38 +481,15 @@ define(function(require, exports, module) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
// Attributes we are happy to set directly
|
||||
var validAttributes = [
|
||||
"value",
|
||||
"visible",
|
||||
"zindex",
|
||||
"disabled",
|
||||
"caption",
|
||||
"tooltip",
|
||||
"command",
|
||||
"class",
|
||||
"icon",
|
||||
"src",
|
||||
"submenu"
|
||||
];
|
||||
|
||||
// supported attributes
|
||||
var validAttributes = /^(value|visible|zindex|disabled|caption|tooltip|command|class|icon|src|submenu)$/;
|
||||
Object.keys(item).forEach(function(key) {
|
||||
// Check for onclick explictly
|
||||
if (key === "onclick")
|
||||
return el.lastChild.onclick = item.onclick;
|
||||
|
||||
return el.onclick = item.onclick;
|
||||
// Check for attributes we know exist and will directly set
|
||||
if (validAttributes.indexOf(key) > -1)
|
||||
return el.lastChild.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]);
|
||||
}
|
||||
if (validAttributes.test(key))
|
||||
return el.setAttribute(key, item[key]);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue