<commit_before>/* global HTMLTemplateElement, HTMLImports, MutationObserver */

window.addEventListener('HTMLImportsLoaded', injectFromPolyfilledImports);

// NOTE: HTML Imports polyfill must come before we include `aframe-core`.
if (!('import' in document.createElement('link'))) {
  require('../lib/vendor/HTMLImports');
}

var aframeCore = require('@mozvr/aframe-core');
var registerTemplate = require('./lib/register-template');
var utils = require('./lib/utils');

var registerElement = aframeCore.registerElement.registerElement;

function injectFromPolyfilledImports () {
  if (!HTMLImports || HTMLImports.useNative) { return; }

  Object.keys(HTMLImports.importer.documents).forEach(function (key) {
    var doc = HTMLImports.importer.documents[key];
    insertTemplateElements(doc);
  });
}

function insertTemplateElements (doc) {
  var sceneEl = utils.$('a-scene');
  var assetsEl = utils.$('a-assets');
  if (!assetsEl) {
    assetsEl = document.createElement('a-assets');
    sceneEl.parentNode.insertBefore(assetsEl, sceneEl);
  }

  utils.$$('a-mixin', doc).forEach(function (mixinEl) {
    var mixinCloneEl = document.importNode(mixinEl, true);
    assetsEl.appendChild(mixinCloneEl);
  });

  utils.$$('template[is="a-template"]', doc).forEach(function (templateEl) {
    var templateCloneEl = document.importNode(templateEl, true);
    document.body.appendChild(templateCloneEl);
    // XXX: Hack for VS to hide templates from source.
    setTimeout(function () {
      document.body.removeChild(templateCloneEl);
    });
  });<commit_msg>remove hack from VS that hid template source from document (fixes #223)<commit_after>/* global HTMLTemplateElement, HTMLImports, MutationObserver */

window.addEventListener('HTMLImportsLoaded', injectFromPolyfilledImports);

// NOTE: HTML Imports polyfill must come before we include `aframe-core`.
if (!('import' in document.createElement('link'))) {
  require('../lib/vendor/HTMLImports');
}

var aframeCore = require('@mozvr/aframe-core');
var registerTemplate = require('./lib/register-template');
var utils = require('./lib/utils');

var registerElement = aframeCore.registerElement.registerElement;

function injectFromPolyfilledImports () {
  if (!HTMLImports || HTMLImports.useNative) { return; }

  Object.keys(HTMLImports.importer.documents).forEach(function (key) {
    var doc = HTMLImports.importer.documents[key];
    insertTemplateElements(doc);
  });
}

function insertTemplateElements (doc) {
  var sceneEl = utils.$('a-scene');
  var assetsEl = utils.$('a-assets');
  if (!assetsEl) {
    assetsEl = document.createElement('a-assets');
    sceneEl.parentNode.insertBefore(assetsEl, sceneEl);
  }

  utils.$$('a-mixin', doc).forEach(function (mixinEl) {
    var mixinCloneEl = document.importNode(mixinEl, true);
    assetsEl.appendChild(mixinCloneEl);
  });

  utils.$$('template[is="a-template"]', doc).forEach(function (templateEl) {
    var templateCloneEl = document.importNode(templateEl, true);
    document.body.appendChild(templateCloneEl);
  });
{'fraction_non_alphanumeric': 0.14752475247524752, 'fraction_numerical': 0.0009900990099009901, 'mean_word_length': 5.185714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6113993', 'n_tokens_mistral': 904, 'n_tokens_neox': 901, 'n_words': 176}