function selection_attr(name, value) {
var fullname = namespace(name);
if (arguments.length < 2) {
// TODO:
if (typeof(arguments[0]) === 'object') {
for(var item in arguments[0]) {
var key = namespace(item);
var todo = arguments[0][item];
this.each((todo == null
? (key.local ? attrRemoveNS : attrRemove) : (typeof todo === "function"
? (key.local ? attrFunctionNS : attrFunction)
: (key.local ? attrConstantNS : attrConstant)))(key, todo));
}
return this
// end TODO:
} else {
var node = this.node();
return fullname.local
? node.getAttributeNS(fullname.space, fullname.local)
: node.getAttribute(fullname);
}
}
return this.each((value == null
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
}
d3 attr修改源碼支持object輸入
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.