Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: polymer_0.5.0/bower_components/webcomponentsjs/HTMLImports.min.js

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt
6 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt
9 */
10 // @version 0.5.1-1
11 "undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now( )%1e9,r=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};r.proto type={set:function(t,r){var n=t[this.name];return n&&n[0]===t?n[1]=r:e(t,this.na me,{value:[t,r],writable:!0}),this},get:function(e){var t;return(t=e[this.name]) &&t[0]===e?t[1]:void 0},"delete":function(e){var t=e[this.name];return t&&t[0]== =e?(t[0]=t[1]=void 0,!0):!1},has:function(e){var t=e[this.name];return t?t[0]=== e:!1}},window.WeakMap=r}(),function(e){function t(e){E.push(e),_||(_=!0,f(n))}fu nction r(e){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeed ed(e)||e}function n(){_=!1;var e=E;E=[],e.sort(function(e,t){return e.uid_-t.uid _});var t=!1;e.forEach(function(e){var r=e.takeRecords();o(e),r.length&&(e.callb ack_(r,e),t=!0)}),t&&n()}function o(e){e.nodes_.forEach(function(t){var r=v.get( t);r&&r.forEach(function(t){t.observer===e&&t.removeTransientObservers()})})}fun ction i(e,t){for(var r=e;r;r=r.parentNode){var n=v.get(r);if(n)for(var o=0;o<n.l ength;o++){var i=n[o],a=i.options;if(r===e||a.subtree){var s=t(a);s&&i.enqueue(s )}}}}function a(e){this.callback_=e,this.nodes_=[],this.records_=[],this.uid_=++ L}function s(e,t){this.type=e,this.target=t,this.addedNodes=[],this.removedNodes =[],this.previousSibling=null,this.nextSibling=null,this.attributeName=null,this .attributeNamespace=null,this.oldValue=null}function d(e){var t=new s(e.type,e.t arget);return t.addedNodes=e.addedNodes.slice(),t.removedNodes=e.removedNodes.sl ice(),t.previousSibling=e.previousSibling,t.nextSibling=e.nextSibling,t.attribut eName=e.attributeName,t.attributeNamespace=e.attributeNamespace,t.oldValue=e.old Value,t}function c(e,t){return y=new s(e,t)}function l(e){return M?M:(M=d(y),M.o ldValue=e,M)}function u(){y=M=void 0}function h(e){return e===M||e===y}function m(e,t){return e===t?e:M&&h(e)?M:null}function p(e,t,r){this.observer=e,this.targ et=t,this.options=r,this.transientObservedNodes=[]}var f,v=new WeakMap;if(/Tride nt|Edge/.test(navigator.userAgent))f=setTimeout;else if(window.setImmediate)f=wi ndow.setImmediate;else{var b=[],g=String(Math.random());window.addEventListener( "message",function(e){if(e.data===g){var t=b;b=[],t.forEach(function(e){e()})}}) ,f=function(e){b.push(e),window.postMessage(g,"*")}}var _=!1,E=[],L=0;a.prototyp e={observe:function(e,t){if(e=r(e),!t.childList&&!t.attributes&&!t.characterData ||t.attributeOldValue&&!t.attributes||t.attributeFilter&&t.attributeFilter.lengt h&&!t.attributes||t.characterDataOldValue&&!t.characterData)throw new SyntaxErro r;var n=v.get(e);n||v.set(e,n=[]);for(var o,i=0;i<n.length;i++)if(n[i].observer= ==this){o=n[i],o.removeListeners(),o.options=t;break}o||(o=new p(this,e,t),n.pus h(o),this.nodes_.push(e)),o.addListeners()},disconnect:function(){this.nodes_.fo rEach(function(e){for(var t=v.get(e),r=0;r<t.length;r++){var n=t[r];if(n.observe r===this){n.removeListeners(),t.splice(r,1);break}}},this),this.records_=[]},tak eRecords:function(){var e=this.records_;return this.records_=[],e}};var y,M;p.pr ototype={enqueue:function(e){var r=this.observer.records_,n=r.length;if(r.length >0){var o=r[n-1],i=m(o,e);if(i)return void(r[n-1]=i)}else t(this.observer);r[n]= e},addListeners:function(){this.addListeners_(this.target)},addListeners_:functi on(e){var t=this.options;t.attributes&&e.addEventListener("DOMAttrModified",this ,!0),t.characterData&&e.addEventListener("DOMCharacterDataModified",this,!0),t.c hildList&&e.addEventListener("DOMNodeInserted",this,!0),(t.childList||t.subtree) &&e.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this. removeListeners_(this.target)},removeListeners_:function(e){var t=this.options;t .attributes&&e.removeEventListener("DOMAttrModified",this,!0),t.characterData&&e .removeEventListener("DOMCharacterDataModified",this,!0),t.childList&&e.removeEv entListener("DOMNodeInserted",this,!0),(t.childList||t.subtree)&&e.removeEventLi stener("DOMNodeRemoved",this,!0)},addTransientObserver:function(e){if(e!==this.t arget){this.addListeners_(e),this.transientObservedNodes.push(e);var t=v.get(e); t||v.set(e,t=[]),t.push(this)}},removeTransientObservers:function(){var e=this.t ransientObservedNodes;this.transientObservedNodes=[],e.forEach(function(e){this. removeListeners_(e);for(var t=v.get(e),r=0;r<t.length;r++)if(t[r]===this){t.spli ce(r,1);break}},this)},handleEvent:function(e){switch(e.stopImmediatePropagation (),e.type){case"DOMAttrModified":var t=e.attrName,r=e.relatedNode.namespaceURI,n =e.target,o=new c("attributes",n);o.attributeName=t,o.attributeNamespace=r;var a =e.attrChange===MutationEvent.ADDITION?null:e.prevValue;i(n,function(e){return!e .attributes||e.attributeFilter&&e.attributeFilter.length&&-1===e.attributeFilter .indexOf(t)&&-1===e.attributeFilter.indexOf(r)?void 0:e.attributeOldValue?l(a):o });break;case"DOMCharacterDataModified":var n=e.target,o=c("characterData",n),a= e.prevValue;i(n,function(e){return e.characterData?e.characterDataOldValue?l(a): o:void 0});break;case"DOMNodeRemoved":this.addTransientObserver(e.target);case"D OMNodeInserted":var s,d,n=e.relatedNode,h=e.target;"DOMNodeInserted"===e.type?(s =[h],d=[]):(s=[],d=[h]);var m=h.previousSibling,p=h.nextSibling,o=c("childList", n);o.addedNodes=s,o.removedNodes=d,o.previousSibling=m,o.nextSibling=p,i(n,funct ion(e){return e.childList?o:void 0})}u()}},e.JsMutationObserver=a,e.MutationObse rver||(e.MutationObserver=a)}(this),window.HTMLImports=window.HTMLImports||{flag s:{}},function(e){function t(e,t){t=t||p,n(function(){i(e,t)},t)}function r(e){r eturn"complete"===e.readyState||e.readyState===b}function n(e,t){if(r(t))e&&e(); else{var o=function(){("complete"===t.readyState||t.readyState===b)&&(t.removeEv entListener(g,o),n(e,t))};t.addEventListener(g,o)}}function o(e){e.target.__load ed=!0}function i(e,t){function r(){s==d&&e&&e()}function n(e){o(e),s++,r()}var i =t.querySelectorAll("link[rel=import]"),s=0,d=i.length;if(d)for(var c,l=0;d>l&&( c=i[l]);l++)a(c)?n.call(c,{target:c}):(c.addEventListener("load",n),c.addEventLi stener("error",n));else r()}function a(e){return u?e.__loaded||e.import&&"loadin g"!==e.import.readyState:e.__importParsed}function s(e){for(var t,r=0,n=e.length ;n>r&&(t=e[r]);r++)d(t)&&c(t)}function d(e){return"link"===e.localName&&"import" ===e.rel}function c(e){var t=e.import;t?o({target:e}):(e.addEventListener("load" ,o),e.addEventListener("error",o))}var l="import",u=Boolean(l in document.create Element("link")),h=Boolean(window.ShadowDOMPolyfill),m=function(e){return h?Shad owDOMPolyfill.wrapIfNeeded(e):e},p=m(document),f={get:function(){var e=HTMLImpor ts.currentScript||document.currentScript||("complete"!==document.readyState?docu ment.scripts[document.scripts.length-1]:null);return m(e)},configurable:!0};Obje ct.defineProperty(document,"_currentScript",f),Object.defineProperty(p,"_current Script",f);var v=/Trident|Edge/.test(navigator.userAgent),b=v?"complete":"intera ctive",g="readystatechange";u&&(new MutationObserver(function(e){for(var t,r=0,n =e.length;n>r&&(t=e[r]);r++)t.addedNodes&&s(t.addedNodes)}).observe(document.hea d,{childList:!0}),function(){if("loading"===document.readyState)for(var e,t=docu ment.querySelectorAll("link[rel=import]"),r=0,n=t.length;n>r&&(e=t[r]);r++)c(e)} ()),t(function(){HTMLImports.ready=!0,HTMLImports.readyTime=(new Date).getTime() ,p.dispatchEvent(new CustomEvent("HTMLImportsLoaded",{bubbles:!0}))}),e.IMPORT_L INK_TYPE=l,e.useNative=u,e.rootDocument=p,e.whenReady=t,e.isIE=v}(HTMLImports),f unction(e){var t=[],r=function(e){t.push(e)},n=function(){t.forEach(function(t){ t(e)})};e.addModule=r,e.initializeModules=n}(HTMLImports),HTMLImports.addModule( function(e){var t=/(url\()([^)]*)(\))/g,r=/(@import[\s]+(?!url\())([^;]*)(;)/g,n ={resolveUrlsInStyle:function(e){var t=e.ownerDocument,r=t.createElement("a");re turn e.textContent=this.resolveUrlsInCssText(e.textContent,r),e},resolveUrlsInCs sText:function(e,n){var o=this.replaceUrls(e,n,t);return o=this.replaceUrls(o,n, r)},replaceUrls:function(e,t,r){return e.replace(r,function(e,r,n,o){var i=n.rep lace(/["']/g,"");return t.href=i,i=t.href,r+"'"+i+"'"+o})}};e.path=n}),HTMLImpor ts.addModule(function(e){xhr={async:!0,ok:function(e){return e.status>=200&&e.st atus<300||304===e.status||0===e.status},load:function(t,r,n){var o=new XMLHttpRe quest;return(e.flags.debug||e.flags.bust)&&(t+="?"+Math.random()),o.open("GET",t ,xhr.async),o.addEventListener("readystatechange",function(){if(4===o.readyState ){var e=o.getResponseHeader("Location"),t=null;if(e)var t="/"===e.substr(0,1)?lo cation.origin+e:e;r.call(n,!xhr.ok(o)&&o,o.response||o.responseText,t)}}),o.send (),o},loadDocument:function(e,t,r){this.load(e,t,r).responseType="document"}},e. xhr=xhr}),HTMLImports.addModule(function(e){var t=e.xhr,r=e.flags,n=function(e,t ){this.cache={},this.onload=e,this.oncomplete=t,this.inflight=0,this.pending={}} ;n.prototype={addNodes:function(e){this.inflight+=e.length;for(var t,r=0,n=e.len gth;n>r&&(t=e[r]);r++)this.require(t);this.checkDone()},addNode:function(e){this .inflight++,this.require(e),this.checkDone()},require:function(e){var t=e.src||e .href;e.__nodeUrl=t,this.dedupe(t,e)||this.fetch(t,e)},dedupe:function(e,t){if(t his.pending[e])return this.pending[e].push(t),!0;return this.cache[e]?(this.onlo ad(e,t,this.cache[e]),this.tail(),!0):(this.pending[e]=[t],!1)},fetch:function(e ,n){if(r.load&&console.log("fetch",e,n),e.match(/^data:/)){var o=e.split(","),i= o[0],a=o[1];a=i.indexOf(";base64")>-1?atob(a):decodeURIComponent(a),setTimeout(f unction(){this.receive(e,n,null,a)}.bind(this),0)}else{var s=function(t,r,o){thi s.receive(e,n,t,r,o)}.bind(this);t.load(e,s)}},receive:function(e,t,r,n,o){this. cache[e]=n;for(var i,a=this.pending[e],s=0,d=a.length;d>s&&(i=a[s]);s++)this.onl oad(e,i,n,r,o),this.tail();this.pending[e]=null},tail:function(){--this.inflight ,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},e.Loa der=n}),HTMLImports.addModule(function(e){var t=function(e){this.addCallback=e,t his.mo=new MutationObserver(this.handler.bind(this))};t.prototype={handler:funct ion(e){for(var t,r=0,n=e.length;n>r&&(t=e[r]);r++)"childList"===t.type&&t.addedN odes.length&&this.addedNodes(t.addedNodes)},addedNodes:function(e){this.addCallb ack&&this.addCallback(e);for(var t,r=0,n=e.length;n>r&&(t=e[r]);r++)t.children&& t.children.length&&this.addedNodes(t.children)},observe:function(e){this.mo.obse rve(e,{childList:!0,subtree:!0})}},e.Observer=t}),HTMLImports.addModule(function (e){function t(e){return"link"===e.localName&&e.rel===l}function r(e){var t=n(e) ;return"data:text/javascript;charset=utf-8,"+encodeURIComponent(t)}function n(e) {return e.textContent+o(e)}function o(e){var t=e.ownerDocument;t.__importedScrip ts=t.__importedScripts||0;var r=e.ownerDocument.baseURI,n=t.__importedScripts?"- "+t.__importedScripts:"";return t.__importedScripts++,"\n//# sourceURL="+r+n+".j s\n"}function i(e){var t=e.ownerDocument.createElement("style");return t.textCon tent=e.textContent,a.resolveUrlsInStyle(t),t}var a=e.path,s=e.rootDocument,d=e.f lags,c=e.isIE,l=e.IMPORT_LINK_TYPE,u="link[rel="+l+"]",h={documentSelectors:u,im portsSelectors:[u,"link[rel=stylesheet]","style","script:not([type])",'script[ty pe="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",sty le:"parseStyle"},dynamicElements:[],parseNext:function(){var e=this.nextToParse( );e&&this.parse(e)},parse:function(e){if(this.isParsed(e))return void(d.parse&&c onsole.log("[%s] is already parsed",e.localName));var t=this[this.map[e.localNam e]];t&&(this.markParsing(e),t.call(this,e))},parseDynamic:function(e,t){this.dyn amicElements.push(e),t||this.parseNext()},markParsing:function(e){d.parse&&conso le.log("parsing",e),this.parsingElement=e},markParsingComplete:function(e){e.__i mportParsed=!0,this.markDynamicParsingComplete(e),e.__importElement&&(e.__import Element.__importParsed=!0,this.markDynamicParsingComplete(e.__importElement)),th is.parsingElement=null,d.parse&&console.log("completed",e)},markDynamicParsingCo mplete:function(e){var t=this.dynamicElements.indexOf(e);t>=0&&this.dynamicEleme nts.splice(t,1)},parseImport:function(e){if(HTMLImports.__importsParsingHook&&HT MLImports.__importsParsingHook(e),e.import&&(e.import.__importParsed=!0),this.ma rkParsingComplete(e),e.dispatchEvent(e.__resource&&!e.__error?new CustomEvent("l oad",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),e.__pending)for(var t; e.__pending.length;)t=e.__pending.shift(),t&&t({target:e});this.parseNext()},par seLink:function(e){t(e)?this.parseImport(e):(e.href=e.href,this.parseGeneric(e)) },parseStyle:function(e){var t=e;e=i(e),e.__importElement=t,this.parseGeneric(e) },parseGeneric:function(e){this.trackElement(e),this.addElementToDocument(e)},ro otImportForElement:function(e){for(var t=e;t.ownerDocument.__importLink;)t=t.own erDocument.__importLink;return t},addElementToDocument:function(e){var t=this.ro otImportForElement(e.__importElement||e);t.parentNode.insertBefore(e,t)},trackEl ement:function(e,t){var r=this,n=function(n){t&&t(n),r.markParsingComplete(e),r. parseNext()};if(e.addEventListener("load",n),e.addEventListener("error",n),c&&"s tyle"===e.localName){var o=!1;if(-1==e.textContent.indexOf("@import"))o=!0;else if(e.sheet){o=!0;for(var i,a=e.sheet.cssRules,s=a?a.length:0,d=0;s>d&&(i=a[d]);d ++)i.type===CSSRule.IMPORT_RULE&&(o=o&&Boolean(i.styleSheet))}o&&e.dispatchEvent (new CustomEvent("load",{bubbles:!1}))}},parseScript:function(t){var n=document. createElement("script");n.__importElement=t,n.src=t.src?t.src:r(t),e.currentScri pt=t,this.trackElement(n,function(){n.parentNode.removeChild(n),e.currentScript= null}),this.addElementToDocument(n)},nextToParse:function(){return this._mayPars e=[],!this.parsingElement&&(this.nextToParseInDoc(s)||this.nextToParseDynamic()) },nextToParseInDoc:function(e,r){if(e&&this._mayParse.indexOf(e)<0){this._mayPar se.push(e);for(var n,o=e.querySelectorAll(this.parseSelectorsForNode(e)),i=0,a=o .length;a>i&&(n=o[i]);i++)if(!this.isParsed(n))return this.hasResource(n)?t(n)?t his.nextToParseInDoc(n.import,n):n:void 0}return r},nextToParseDynamic:function( ){return this.dynamicElements[0]},parseSelectorsForNode:function(e){var t=e.owne rDocument||e;return t===s?this.documentSelectors:this.importsSelectors},isParsed :function(e){return e.__importParsed},needsDynamicParsing:function(e){return thi s.dynamicElements.indexOf(e)>=0},hasResource:function(e){return t(e)&&void 0===e .import?!1:!0}};e.parser=h,e.IMPORT_SELECTOR=u}),HTMLImports.addModule(function( e){function t(e){return r(e,i)}function r(e,t){return"link"===e.localName&&e.get Attribute("rel")===t}function n(e,t){var r=document.implementation.createHTMLDoc ument(i);r._URL=t;var n=r.createElement("base");n.setAttribute("href",t),r.baseU RI||Object.defineProperty(r,"baseURI",{value:t});var o=r.createElement("meta");r eturn o.setAttribute("charset","utf-8"),r.head.appendChild(o),r.head.appendChild (n),r.body.innerHTML=e,window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap &&HTMLTemplateElement.bootstrap(r),r}var o=e.flags,i=e.IMPORT_LINK_TYPE,a=e.IMPO RT_SELECTOR,s=e.rootDocument,d=e.Loader,c=e.Observer,l=e.parser,u={documents:{}, documentPreloadSelectors:a,importsPreloadSelectors:[a].join(","),loadNode:functi on(e){h.addNode(e)},loadSubtree:function(e){var t=this.marshalNodes(e);h.addNode s(t)},marshalNodes:function(e){return e.querySelectorAll(this.loadSelectorsForNo de(e))},loadSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?t his.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(e,r,i ,a,s){if(o.load&&console.log("loaded",e,r),r.__resource=i,r.__error=a,t(r)){var d=this.documents[e];void 0===d&&(d=a?null:n(i,s||e),d&&(d.__importLink=r,this.bo otDocument(d)),this.documents[e]=d),r.import=d}l.parseNext()},bootDocument:funct ion(e){this.loadSubtree(e),this.observer.observe(e),l.parseNext()},loadedAll:fun ction(){l.parseNext()}},h=new d(u.loaded.bind(u),u.loadedAll.bind(u));if(u.obser ver=new c,!document.baseURI){var m={get:function(){var e=document.querySelector( "base");return e?e.href:window.location.href},configurable:!0};Object.defineProp erty(document,"baseURI",m),Object.defineProperty(s,"baseURI",m)}e.importer=u,e.i mportLoader=h}),HTMLImports.addModule(function(e){var t=e.parser,r=e.importer,n= {added:function(e){for(var n,o,i,a=0,s=e.length;s>a&&(i=e[a]);a++)n||(n=i.ownerD ocument,o=t.isParsed(n)),loading=this.shouldLoadNode(i),loading&&r.loadNode(i),t his.shouldParseNode(i)&&o&&t.parseDynamic(i,loading)},shouldLoadNode:function(e) {return 1===e.nodeType&&o.call(e,r.loadSelectorsForNode(e))},shouldParseNode:fun ction(e){return 1===e.nodeType&&o.call(e,t.parseSelectorsForNode(e))}};r.observe r.addCallback=n.added.bind(n);var o=HTMLElement.prototype.matches||HTMLElement.p rototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLEleme nt.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector}),funct ion(e){function t(){HTMLImports.importer.bootDocument(o)}var r=e.initializeModul es,n=e.isIE;if(!e.useNative){n&&"function"!=typeof window.CustomEvent&&(window.C ustomEvent=function(e,t){t=t||{};var r=document.createEvent("CustomEvent");retur n r.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),r},wind ow.CustomEvent.prototype=window.Event.prototype),r();var o=e.rootDocument;"compl ete"===document.readyState||"interactive"===document.readyState&&!window.attachE vent?t():document.addEventListener("DOMContentLoaded",t)}}(HTMLImports);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698