5 examples of 'document.head.appendchild' in JavaScript

Every line of 'document.head.appendchild' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
80export function addStyleToHead(style, attr, parent) {
81 //parent is shadowroot
82 if (parent || !options.staticStyleMapping[attr]) {
83 "undefined" != typeof wx && wx.getSystemInfoSync || addStyle(scoper(style, attr), attr, parent)
84 //don't cache when is shadowroot
85 if(!parent){
86 options.staticStyleMapping[attr] = true
87 }
88 }
89}
197public addStyleSheet() {
198 const sheet = this.documentStyleSheet();
199 if (sheet) {
200 const head = this.adaptor.head(this.document);
201 let styles = this.findSheet(head, this.adaptor.getAttribute(sheet, 'id'));
202 if (styles) {
203 this.adaptor.replace(sheet, styles);
204 } else {
205 this.adaptor.append(head, sheet);
206 }
207 }
208}
332function addStyleSheet(document) {
333 var styles = document.getElementsByTagName("style"),
334 head = document.getElementsByTagName('head')[0],
335 text = '', prefix, a = "", b;
336 // use cloneNode on an exisiting HTMLStyleElement, because in
337 // Chromium 12, document.createElement('style') does not give a
338 // HTMLStyleElement
339 if (styles && styles.length > 0) {
340 styles = styles[0].cloneNode(false);
341 } else {
342 styles = document.createElement('style');
343 }
344 for (prefix in namespaces) {
345 if (prefix) {
346 text += "@namespace " + prefix + " url(" + namespaces[prefix] +
347 ");\n";
348 }
349 }
350 styles.appendChild(document.createTextNode(text));
351 head.appendChild(styles);
352 return styles;
353}
187function addElementToHead(element, asFirstChildElement) {
188 var firstElement;
189
190 if (head) {
191 if (asFirstChildElement) {
192 firstElement = head.firstElementChild;
193 if (firstElement) {
194 head.insertBefore(element, firstElement);
195 return;
196 }
197 }
198 head.appendChild(element);
199 }
200}
3export function addToHead(head: any, element: any) {
4 var newNode = new Node(element)
5
6 newNode.next = head
7
8 return newNode
9}

Related snippets