All files dom.js

100% Statements 12/12
80% Branches 4/5
100% Functions 4/4
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35    4x             115x       52x       132x   132x 132x 245x 245x     132x 132x       34x   34x    
import { forEach } from './utils';
 
export const canUseDOM = !!(
  typeof window !== 'undefined' &&
  window.document &&
  window.document.createElement
);
 
function removeNode(node) {
  node.parentNode.removeChild(node);
}
 
export function removeDocumentMeta() {
  forEach(document.querySelectorAll('head [data-rdm]'), removeNode);
}
 
function insertDocumentMetaNode(entry) {
  const { tagName, ...attr } = entry;
 
  var newNode = document.createElement(tagName);
  for (var prop in attr) {
    Eif (entry.hasOwnProperty(prop)) {
      newNode.setAttribute(prop, entry[prop]);
    }
  }
  newNode.setAttribute('data-rdm', '');
  document.getElementsByTagName('head')[0].appendChild(newNode);
}
 
export function insertDocumentMeta(nodes) {
  removeDocumentMeta();
 
  forEach(nodes, insertDocumentMetaNode);
}