Every line of 'document body innerhtml' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
41 export function needsInnerHTMLFix(document: Document) { 42 let table = document.createElement('table'); 43 try { 44 table.innerHTML = '<tbody></tbody>'; 45 } catch (e) { 46 } finally { 47 if (table.childNodes.length !== 0) { 48 // It worked as expected, no fix required 49 return false; 50 } 51 } 52 53 return true; 54 }
62 export function setInnerHTML(container, html) { 63 if (typeof container.innerHTML != T_UNDEF) container.innerHTML = html 64 // some browsers do not support innerHTML on the SVGs tags 65 else { 66 var doc = new DOMParser().parseFromString(html, 'application/xml') 67 container.appendChild( 68 container.ownerDocument.importNode(doc.documentElement, true) 69 ) 70 } 71 }
29 get innerHTML() { 30 return this.el.getContent(); 31 }
19 export function setDocument(document, html) { 20 return { 21 type: types.SET_DOCUMENT, 22 document, 23 html 24 }; 25 }
52 function getFragmentInnerHTML(fragment) { 53 var tmp = document.createElement('body'); 54 tmp.appendChild(fragment.cloneNode(true)); 55 return tmp.innerHTML; 56 }
24 function getSafeBodyFromHTML(html: string): ?Element { 25 let doc; 26 let root = null; 27 // Provides a safe context 28 if ( 29 !isOldIE && 30 document.implementation && 31 document.implementation.createHTMLDocument 32 ) { 33 doc = document.implementation.createHTMLDocument('foo'); 34 invariant(doc.documentElement, 'Missing doc.documentElement'); 35 doc.documentElement.innerHTML = html; 36 root = doc.getElementsByTagName('body')[0]; 37 } 38 return root; 39 }
59 getBodyElement(): HTMLElement { 60 return this.model.file.getContentDocument().body; 61 }
8 function testHTMLDocument(document) { 9 assert.strictEqual(document.getElementsByTagName("body").length, 1); 10 assert.strictEqual(document.getElementsByTagName("p").length, 1); 11 assert.strictEqual(document.getElementsByTagName("img").length, 1); 12 13 const p = document.getElementsByTagName("p")[0]; 14 assert.strictEqual(p.prefix, null, "tag prefixes in html documents should always be null"); 15 assert.strictEqual(p.localName, "p", "localNames in html documents always equal the tag name"); 16 assert.strictEqual( 17 p.namespaceURI, "http://www.w3.org/1999/xhtml", 18 "html elements should automatically be assigned the XHTML namespace" 19 ); 20 21 assert.strictEqual( 22 p.getAttribute("xmlns:xlink"), "http://www.w3.org/1999/xlink", 23 "attributes should be retrievable by their full name" 24 ); 25 26 const xmlnsAttr = p.attributes["xmlns:xlink"]; 27 assert.strictEqual(xmlnsAttr.prefix, null, "attribute prefixes should be detected"); 28 assert.strictEqual(xmlnsAttr.localName, "xmlns:xlink", "attribute localNames should be detected"); 29 assert.strictEqual( 30 xmlnsAttr.namespaceURI, null, 31 "xmlns: attributes should not automatically be assigned to the xmlns namespace" 32 ); 33 34 const img = document.getElementsByTagName("img")[0]; 35 assert.strictEqual(img.prefix, null, "tag prefixes in html documents should always be null"); 36 assert.strictEqual(img.localName, "img", "localNames in html documents always equal the tag name"); 37 assert.strictEqual( 38 img.namespaceURI, "http://www.w3.org/1999/xhtml", 39 "html elements should automatically be assigned the XHTML namespace" 40 ); 41 42 assert.strictEqual( 43 img.getAttribute("xlink:href"), "#test", 44 "attributes should be retrievable by their full name" 45 ); 46 47 const xlinkAttr = img.attributes["xlink:href"]; 48 assert.strictEqual(xlinkAttr.prefix, null, "attribute prefixes should be detected"); 49 assert.strictEqual(xlinkAttr.localName, "xlink:href", "attribute localNames should be detected"); 50 assert.strictEqual( 51 xlinkAttr.namespaceURI, null, 52 "it shouldn't be possible to create custom namespaces" 53 ); 54 }
1264 function setHTML(elem, html) 1265 { 1266 while (elem.firstChild) 1267 elem.removeChild(elem.firstChild); 1268 elem.appendChild(parseToHTML(elem.ownerDocument, html)); 1269 }
169 function innerHtml(node) { 170 if (node.nodeType === ELEMENT_NODE) 171 return node.innerHTML; 172 if (node.nodeType === TEXT_NODE) 173 return node.textContent; 174 if (node.nodeType === COMMENT_NODE) 175 return ''; 176 if (isConnected(node)) 177 return node.innerHTML; 178 return null; 179 }