<commit_before>import { eachChildNode, eachNodeOrFragmentNodes } from './util/each';
import canPatchNativeAccessors from './util/can-patch-native-accessors';
import debounce from 'debounce';
import version from './version';
import WeakMap from './util/weak-map';

// We use a real DOM node for a shadow root. This is because the host node
// basically becomes a virtual entry point for your element leaving the shadow
// root the only thing that can receive instructions on how the host should
// render to the browser.
const defaultShadowRootTagName = '_shadow_root_';
const defaultShadowRootTagNameUc = defaultShadowRootTagName.toUpperCase();

// * WebKit only *
//
// These members we need cannot override as we require native access to their
// original values at some point.
const polyfillAtRuntime = ['childNodes', 'parentNode'];

// These are the protos that we need to search for native descriptors on.
const protos = ['Node', 'Element', 'EventTarget'];

// Private data stores.
const assignedToSlotMap = new WeakMap();
const hostToModeMap = new WeakMap();
const hostToRootMap = new WeakMap();
const nodeToChildNodesMap = new WeakMap();
const nodeToParentNodeMap = new WeakMap();
const nodeToSlotMap = new WeakMap();
const rootToHostMap = new WeakMap();
const rootToSlotMap = new WeakMap();
const slotToModeMap = new WeakMap();


// * WebKit only *
//
// We require some way to parse HTML natively because we can't use the native
// accessors. To do this we parse as XML and convert each node in the tree to
// HTML nodes.
//
// This works because we polyfill at the HTMLElement level and XML nodes are
// considered Element nodes and we don't polyfill at that level.

const parser = new DOMParser();

function convertXmlToHtml (node) {
  const { nodeType } = node;
  if (nodeType === 1) {
    const copy = document.createElement(node.tagName);
    for (let a = 0; a < node.attributes.length; a++) {
      const attr = node.attributes[a];
      copy.setAttribute(attr.name, attr.value);
    }
    for (let a = 0; a < node.childNodes.length; a++) {
      const childNode = node.childNodes[a];
      copy.appendChild(convertXmlToHtml(childNode));
    }
    return copy;
  }
  return node;
}

function parse (html) {
  const tree = document.createElement('div');
  const wrappedHtml = `<div>${html}</div>`; // We need to wrap HTML as the XML parser requires one parent node
  const wrappedParsed = parser.parseFromString(wrappedHtml, 'text/xml');
  const parsed = wrappedParsed.firstChild;
  while (parsed.hasChildNodes()) {
    const firstChild = parsed.firstChild;
    parsed.removeChild(firstChild);
    tree.appendChild(convertXmlToHtml(firstChild));
  }
  return tree;
}


function staticProp (obj, name, value) {
  Object.defineProperty(obj, name, {
    configurable: true,
    get () { return value; }
  });
}


// Slotting helpers.

function arrayItem (idx) {
  return this[idx];
}

function makeLikeNodeList (arr) {
  arr.item = arrayItem;
  return arr;
}

function getNodeType (node) {
  if (isHostNode(node)) {
    return 'host';<commit_msg>Fixes #28 - div.innerHTML = '<div checked></div>';<commit_after>import { eachChildNode, eachNodeOrFragmentNodes } from './util/each';
import canPatchNativeAccessors from './util/can-patch-native-accessors';
import debounce from 'debounce';
import version from './version';
import WeakMap from './util/weak-map';

// We use a real DOM node for a shadow root. This is because the host node
// basically becomes a virtual entry point for your element leaving the shadow
// root the only thing that can receive instructions on how the host should
// render to the browser.
const defaultShadowRootTagName = '_shadow_root_';
const defaultShadowRootTagNameUc = defaultShadowRootTagName.toUpperCase();

// * WebKit only *
//
// These members we need cannot override as we require native access to their
// original values at some point.
const polyfillAtRuntime = ['childNodes', 'parentNode'];

// These are the protos that we need to search for native descriptors on.
const protos = ['Node', 'Element', 'EventTarget'];

// Private data stores.
const assignedToSlotMap = new WeakMap();
const hostToModeMap = new WeakMap();
const hostToRootMap = new WeakMap();
const nodeToChildNodesMap = new WeakMap();
const nodeToParentNodeMap = new WeakMap();
const nodeToSlotMap = new WeakMap();
const rootToHostMap = new WeakMap();
const rootToSlotMap = new WeakMap();
const slotToModeMap = new WeakMap();


// * WebKit only *
//
// We require some way to parse HTML natively because we can't use the native
// accessors.

const parser = new DOMParser();

function parse (html) {
  const tree = document.createElement('div');
  const parsed = parser.parseFromString(html, 'text/html').body;
  while (parsed.hasChildNodes()) {
    const firstChild = parsed.firstChild;
    parsed.removeChild(firstChild);
    tree.appendChild(firstChild);
  }
  return tree;
}

function staticProp (obj, name, value) {
  Object.defineProperty(obj, name, {
    configurable: true,
    get () { return value; }
  });
}


// Slotting helpers.

function arrayItem (idx) {
  return this[idx];
}

function makeLikeNodeList (arr) {
  arr.item = arrayItem;
  return arr;
}

function getNodeType (node) {
  if (isHostNode(node)) {
    return 'host';
{'fraction_non_alphanumeric': 0.1104982883225561, 'fraction_numerical': 0.0009509319132750095, 'mean_word_length': 4.110787172011662, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3250170', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1505, 'n_words': 555}