<commit_before>/*
 * Copyright 2013 The Polymer Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file.
 */
(function(scope) {

  // imports
  
  var extend = Polymer.extend;
  var apis = scope.api.declaration;

  // imperative implementation: Polymer()
  
  // maps tag names to prototypes
  var registry = {};

  function getRegisteredPrototype(name) {
    return registry[name];
  }

  // elements waiting for prototype, by name
  var waitPrototype = {};

  // specify an 'own' prototype for tag `name`
  function element(name, prototype) {
    // cache the prototype
    registry[name] = prototype || {};
    // notify the registrar waiting for 'name', if any
    notifyPrototype(name);
  }

  function notifyPrototype(name) {
    if (waitPrototype[name]) {
      waitPrototype[name].registerWhenReady();
    }
  }

  // elements waiting for super, by name
  var waitSuper = {};

  function notifySuper(name) {
    var waiting = waitSuper[name];
    if (waiting) {
      waiting.forEach(function(w) {
        w.registerWhenReady();
      });
    }
  }

  // returns a prototype that chains to <tag> or HTMLElement
  function generatePrototype(tag) {
    return Object.create(HTMLElement.getPrototypeForTag(tag));
  }
  
  // On platforms that do not support __proto__ (IE10), the prototype chain
  // of a custom element is simulated via installation of __proto__.
  // Although custom elements manages this, we install it here so it's 
  // available during desugaring.
  function ensurePrototypeTraversal(prototype) {
    if (!Object.__proto__) {
      var ancestor = Object.getPrototypeOf(prototype);
      prototype.__proto__ = ancestor;
      if (scope.isBase(ancestor)) {
        ancestor.__proto__ = Object.getPrototypeOf(ancestor);
      }
    }
  }

  // declarative implementation: <polymer-element>

  var prototype = generatePrototype();

  extend(prototype, {
    // TODO(sjmiles): temporary BC
    readyCallback: function() {
      this.createdCallback();
    },
    createdCallback: function() {
      // fetch the element name
      this.name = this.getAttribute('name');
      // install element definition, if ready
      this.registerWhenReady();
    },
    registerWhenReady: function() {
      var name = this.name;
      // if we have no prototype
      if (!getRegisteredPrototype(name)) {
        // then wait for a prototype
        waitPrototype[name] = this;
        // if we are not explicitly async,
        // then wait for end of microtask(-ish)
        // and use whatever prototype is available
        if (!this.hasAttribute('async')) {
          setTimeout(function() {
            if (!getRegisteredPrototype(name)) {
              element(name, null);
            }
          }, 0);
        }
        return;
      }
      // fetch our extendee name
      var extnds = this.getAttribute('extends');
      // if extending a custom element...
      if (extnds && extnds.indexOf('-') >= 0) {
        // wait for the extendee to be registered first<commit_msg>punt 'async' for 'noscript' because of imports-polyfill timing; remove wait list entries after using them<commit_after>/*
 * Copyright 2013 The Polymer Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file.
 */
(function(scope) {

  // imports
  
  var extend = Polymer.extend;
  var apis = scope.api.declaration;

  // imperative implementation: Polymer()
  
  // maps tag names to prototypes
  var registry = {};

  function getRegisteredPrototype(name) {
    return registry[name];
  }

  // elements waiting for prototype, by name
  var waitPrototype = {};

  // specify an 'own' prototype for tag `name`
  function element(name, prototype) {
    //console.log('registering [' + name + ']');
    // cache the prototype
    registry[name] = prototype || {};
    // notify the registrar waiting for 'name', if any
    notifyPrototype(name);
  }

  function notifyPrototype(name) {
    if (waitPrototype[name]) {
      waitPrototype[name].registerWhenReady();
      delete waitPrototype[name];
    }
  }

  // elements waiting for super, by name
  var waitSuper = {};

  function notifySuper(name) {
    var waiting = waitSuper[name];
    if (waiting) {
      waiting.forEach(function(w) {
        w.registerWhenReady();
      });
      delete waitSuper[name];
    }
  }

  // returns a prototype that chains to <tag> or HTMLElement
  function generatePrototype(tag) {
    return Object.create(HTMLElement.getPrototypeForTag(tag));
  }
  
  // On platforms that do not support __proto__ (IE10), the prototype chain
  // of a custom element is simulated via installation of __proto__.
  // Although custom elements manages this, we install it here so it's 
  // available during desugaring.
  function ensurePrototypeTraversal(prototype) {
    if (!Object.__proto__) {
      var ancestor = Object.getPrototypeOf(prototype);
      prototype.__proto__ = ancestor;
      if (scope.isBase(ancestor)) {
        ancestor.__proto__ = Object.getPrototypeOf(ancestor);
      }
    }
  }

  // declarative implementation: <polymer-element>

  var prototype = generatePrototype();

  extend(prototype, {
    // TODO(sjmiles): temporary BC
    readyCallback: function() {
      this.createdCallback();
    },
    createdCallback: function() {
      // fetch the element name
      this.name = this.getAttribute('name');
      // install element definition, if ready
      this.registerWhenReady();
    },
    registerWhenReady: function() {
      var name = this.name;
      // if we have no prototype
      if (!getRegisteredPrototype(name)) {
        // then wait for a prototype
        waitPrototype[name] = this;
        // TODO(sjmiles): there is currently a massive delay between parsing
        // HTML in imports and executing script that foils this `async` gambit
        // Ideally the import polyfill has timing closer to the real deal; in
        // the meantime, invert the strategy and require `noscript` marking
        // instead.
        /*
        // if we are not explicitly async,
        // then wait for end of microtask(-ish)
        // and use whatever prototype is available
        if (!this.hasAttribute('async')) {
          setTimeout(function() {
            if (!getRegisteredPrototype(name)) {
              console.warn('giving up waiting for script for [' + name + ']');
              element(name, null);
            }
          }, 3000);
        }
        */
        if (this.hasAttribute('noscript')) {
          // go async so the parser can process the element's children before
          // registration
          setTimeout(function() {
            element(name, null);
          }, 0);
        }
        return;
      }
      // fetch our extendee name
      var extnds = this.getAttribute('extends');
      // if extending a custom element...
      if (extnds && extnds.indexOf('-') >= 0) {
        // wait for the extendee to be registered first
{'fraction_non_alphanumeric': 0.10665529010238908, 'fraction_numerical': 0.002844141069397042, 'mean_word_length': 2.485133795837463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2868565', 'n_tokens_mistral': 1929, 'n_tokens_neox': 1895, 'n_words': 610}