site/node_modules/d3-selection/src/creator.js
2024-10-14 08:09:33 +02:00

26 lines
668 B
JavaScript

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);
}