site/node_modules/d3-selection/src/creator.js

26 lines
668 B
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
import namespace from "./namespace.js";
import {xhtml} from "./namespaces.js";
function creatorInherit(name) {
return function() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri === xhtml && document.documentElement.namespaceURI === xhtml
? document.createElement(name)
: document.createElementNS(uri, name);
};
}
function creatorFixed(fullname) {
return function() {
return this.ownerDocument.createElementNS(fullname.space, fullname.local);
};
}
export default function(name) {
var fullname = namespace(name);
return (fullname.local
? creatorFixed
: creatorInherit)(fullname);
}