MCPcopy
hub / github.com/Modernizr/Modernizr / createElement

Function createElement

src/html5shiv.js:136–164  ·  view source on GitHub ↗

* returns a shived element for the given nodeName and document * @memberOf html5 * @param {String} nodeName name of the element * @param {Document|DocumentFragment} ownerDocument The context document. * @returns {Object} The shived element.

(nodeName, ownerDocument, data)

Source from the content-addressed store, hash-verified

134 * @returns {Object} The shived element.
135 */
136 function createElement(nodeName, ownerDocument, data){
137 if (!ownerDocument) {
138 ownerDocument = document;
139 }
140 if(supportsUnknownElements){
141 return ownerDocument.createElement(nodeName);
142 }
143 if (!data) {
144 data = getExpandoData(ownerDocument);
145 }
146 var node;
147
148 if (data.cache[nodeName]) {
149 node = data.cache[nodeName].cloneNode();
150 } else if (saveClones.test(nodeName)) {
151 node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
152 } else {
153 node = data.createElem(nodeName);
154 }
155
156 // Avoid adding some elements to fragments in IE < 9 because
157 // * Attributes like `name` or `type` cannot be set/changed once an element
158 // is inserted into a document/fragment
159 // * Link elements with `src` attributes that are inaccessible, as with
160 // a 403 response, will cause the tab/window to crash
161 // * Script elements appended to fragments will execute when their `src`
162 // or `text` property is set
163 return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
164 }
165
166 /**
167 * returns a shived DocumentFragment for the given document

Callers 15

innerFunction · 0.70
shivMethodsFunction · 0.70
testPropsFunction · 0.70
modElem.jsFile · 0.70
getBodyFunction · 0.70
prefixedCSSValueFunction · 0.70
inputElem.jsFile · 0.70
injectElementWithStylesFunction · 0.70
canvas.jsFile · 0.50
flash.jsFile · 0.50
input.jsFile · 0.50
video.jsFile · 0.50

Calls 1

getExpandoDataFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…