1 | import namespace from "./namespace";
|
2 | import {xhtml} from "./namespaces";
|
3 |
|
4 | function creatorInherit(name) {
|
5 | return function() {
|
6 | var document = this.ownerDocument,
|
7 | uri = this.namespaceURI;
|
8 | return uri === xhtml && document.documentElement.namespaceURI === xhtml
|
9 | ? document.createElement(name)
|
10 | : document.createElementNS(uri, name);
|
11 | };
|
12 | }
|
13 |
|
14 | function creatorFixed(fullname) {
|
15 | return function() {
|
16 | return this.ownerDocument.createElementNS(fullname.space, fullname.local);
|
17 | };
|
18 | }
|
19 |
|
20 | export default function(name) {
|
21 | var fullname = namespace(name);
|
22 | return (fullname.local
|
23 | ? creatorFixed
|
24 | : creatorInherit)(fullname);
|
25 | }
|