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

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

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 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.4
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 u(e){return M?M:(M=d(y),M.o ldValue=e,M)}function l(){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?u(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?u(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})}l()}},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,u=0;d>u&&( c=i[u]);u++)a(c)?n.call(c,{target:c}):(c.addEventListener("load",n),c.addEventLi stener("error",n));else r()}function a(e){return l?e.__loaded||e["import"]&&"loa ding"!==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&&"i mport"===e.rel}function c(e){var t=e["import"];t?o({target:e}):(e.addEventListen er("load",o),e.addEventListener("error",o))}var u="import",l=Boolean(u in docume nt.createElement("link")),h=Boolean(window.ShadowDOMPolyfill),m=function(e){retu rn h?ShadowDOMPolyfill.wrapIfNeeded(e):e},p=m(document),f={get:function(){var e= HTMLImports.currentScript||document.currentScript||("complete"!==document.readyS tate?document.scripts[document.scripts.length-1]:null);return m(e)},configurable :!0};Object.defineProperty(document,"_currentScript",f),Object.defineProperty(p, "_currentScript",f);var v=/Trident|Edge/.test(navigator.userAgent),b=v?"complete ":"interactive",g="readystatechange";l&&(new MutationObserver(function(e){for(va r t,r=0,n=e.length;n>r&&(t=e[r]);r++)t.addedNodes&&s(t.addedNodes)}).observe(doc ument.head,{childList:!0}),function(){if("loading"===document.readyState)for(var e,t=document.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();var e=p.createEvent("CustomEvent");e.initCustomEvent("HTMLImportsLoade d",!0,!0,{}),p.dispatchEvent(e)}),e.IMPORT_LINK_TYPE=u,e.useNative=l,e.rootDocum ent=p,e.whenReady=t,e.isIE=v}(HTMLImports),function(e){var t=[],r=function(e){t. push(e)},n=function(){t.forEach(function(t){t(e)})};e.addModule=r,e.initializeMo dules=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");return e.textContent=this.resolveUrlsI nCssText(e.textContent,r),e},resolveUrlsInCssText:function(e,n){var o=this.repla ceUrls(e,n,t);return o=this.replaceUrls(o,n,r)},replaceUrls:function(e,t,r){retu rn e.replace(r,function(e,r,n,o){var i=n.replace(/["']/g,"");return t.href=i,i=t .href,r+"'"+i+"'"+o})}};e.path=n}),HTMLImports.addModule(function(e){var t={asyn c:!0,ok:function(e){return e.status>=200&&e.status<300||304===e.status||0===e.st atus},load:function(r,n,o){var i=new XMLHttpRequest;return(e.flags.debug||e.flag s.bust)&&(r+="?"+Math.random()),i.open("GET",r,t.async),i.addEventListener("read ystatechange",function(){if(4===i.readyState){var e=i.getResponseHeader("Locatio n"),r=null;if(e)var r="/"===e.substr(0,1)?location.origin+e:e;n.call(o,!t.ok(i)& &i,i.response||i.responseText,r)}}),i.send(),i},loadDocument:function(e,t,r){thi s.load(e,t,r).responseType="document"}};e.xhr=t}),HTMLImports.addModule(function (e){var t=e.xhr,r=e.flags,n=function(e,t){this.cache={},this.onload=e,this.oncom plete=t,this.inflight=0,this.pending={}};n.prototype={addNodes:function(e){this. inflight+=e.length;for(var t,r=0,n=e.length;n>r&&(t=e[r]);r++)this.require(t);th is.checkDone()},addNode:function(e){this.inflight++,this.require(e),this.checkDo ne()},require:function(e){var t=e.src||e.href;e.__nodeUrl=t,this.dedupe(t,e)||th is.fetch(t,e)},dedupe:function(e,t){if(this.pending[e])return this.pending[e].pu sh(t),!0;return this.cache[e]?(this.onload(e,t,this.cache[e]),this.tail(),!0):(t his.pending[e]=[t],!1)},fetch:function(e,n){if(r.load&&console.log("fetch",e,n), e)if(e.match(/^data:/)){var o=e.split(","),i=o[0],a=o[1];a=i.indexOf(";base64")> -1?atob(a):decodeURIComponent(a),setTimeout(function(){this.receive(e,n,null,a)} .bind(this),0)}else{var s=function(t,r,o){this.receive(e,n,t,r,o)}.bind(this);t. load(e,s)}else setTimeout(function(){this.receive(e,n,{error:"href must be speci fied"},null)}.bind(this),0)},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.onload(e,i,n,r,o),thi s.tail();this.pending[e]=null},tail:function(){--this.inflight,this.checkDone()} ,checkDone:function(){this.inflight||this.oncomplete()}},e.Loader=n}),HTMLImport s.addModule(function(e){var t=function(e){this.addCallback=e,this.mo=new Mutatio nObserver(this.handler.bind(this))};t.prototype={handler:function(e){for(var t,r =0,n=e.length;n>r&&(t=e[r]);r++)"childList"===t.type&&t.addedNodes.length&&this. addedNodes(t.addedNodes)},addedNodes:function(e){this.addCallback&&this.addCallb ack(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.observe(e,{childList:! 0,subtree:!0})}},e.Observer=t}),HTMLImports.addModule(function(e){function t(e){ return"link"===e.localName&&e.rel===u}function r(e){var t=n(e);return"data:text/ javascript;charset=utf-8,"+encodeURIComponent(t)}function n(e){return e.textCont ent+o(e)}function o(e){var t=e.ownerDocument;t.__importedScripts=t.__importedScr ipts||0;var r=e.ownerDocument.baseURI,n=t.__importedScripts?"-"+t.__importedScri pts:"";return t.__importedScripts++,"\n//# sourceURL="+r+n+".js\n"}function i(e) {var t=e.ownerDocument.createElement("style");return t.textContent=e.textContent ,a.resolveUrlsInStyle(t),t}var a=e.path,s=e.rootDocument,d=e.flags,c=e.isIE,u=e. IMPORT_LINK_TYPE,l="link[rel="+u+"]",h={documentSelectors:l,importsSelectors:[l, "link[rel=stylesheet]","style","script:not([type])",'script[type="text/javascrip t"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},d ynamicElements:[],parseNext:function(){var e=this.nextToParse();e&&this.parse(e) },parse:function(e){if(this.isParsed(e))return void(d.parse&&console.log("[%s] i s already parsed",e.localName));var t=this[this.map[e.localName]];t&&(this.markP arsing(e),t.call(this,e))},parseDynamic:function(e,t){this.dynamicElements.push( e),t||this.parseNext()},markParsing:function(e){d.parse&&console.log("parsing",e ),this.parsingElement=e},markParsingComplete:function(e){e.__importParsed=!0,thi s.markDynamicParsingComplete(e),e.__importElement&&(e.__importElement.__importPa rsed=!0,this.markDynamicParsingComplete(e.__importElement)),this.parsingElement= null,d.parse&&console.log("completed",e)},markDynamicParsingComplete:function(e) {var t=this.dynamicElements.indexOf(e);t>=0&&this.dynamicElements.splice(t,1)},p arseImport:function(e){if(HTMLImports.__importsParsingHook&&HTMLImports.__import sParsingHook(e),e["import"]&&(e["import"].__importParsed=!0),this.markParsingCom plete(e),e.dispatchEvent(e.__resource&&!e.__error?new CustomEvent("load",{bubble s:!1}):new CustomEvent("error",{bubbles:!1})),e.__pending)for(var t;e.__pending. length;)t=e.__pending.shift(),t&&t({target:e});this.parseNext()},parseLink:funct ion(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)},parseGener ic:function(e){this.trackElement(e),this.addElementToDocument(e)},rootImportForE lement:function(e){for(var t=e;t.ownerDocument.__importLink;)t=t.ownerDocument._ _importLink;return t},addElementToDocument:function(e){var t=this.rootImportForE lement(e.__importElement||e);t.parentNode.insertBefore(e,t)},trackElement:functi on(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&&"style"===e.lo calName){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 CustomE vent("load",{bubbles:!1}))}},parseScript:function(t){var n=document.createElemen t("script");n.__importElement=t,n.src=t.src?t.src:r(t),e.currentScript=t,this.tr ackElement(n,function(){n.parentNode.removeChild(n),e.currentScript=null}),this. addElementToDocument(n)},nextToParse:function(){return this._mayParse=[],!this.p arsingElement&&(this.nextToParseInDoc(s)||this.nextToParseDynamic())},nextToPars eInDoc:function(e,r){if(e&&this._mayParse.indexOf(e)<0){this._mayParse.push(e);f or(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)?this.nextToPa rseInDoc(n["import"],n):n:void 0}return r},nextToParseDynamic:function(){return this.dynamicElements[0]},parseSelectorsForNode:function(e){var t=e.ownerDocument ||e;return t===s?this.documentSelectors:this.importsSelectors},isParsed:function (e){return e.__importParsed},needsDynamicParsing:function(e){return this.dynamic Elements.indexOf(e)>=0},hasResource:function(e){return t(e)&&void 0===e["import" ]?!1:!0}};e.parser=h,e.IMPORT_SELECTOR=l}),HTMLImports.addModule(function(e){fun ction t(e){return r(e,i)}function r(e,t){return"link"===e.localName&&e.getAttrib ute("rel")===t}function n(e,t){var r=document.implementation.createHTMLDocument( i);r._URL=t;var n=r.createElement("base");n.setAttribute("href",t),r.baseURI||Ob ject.defineProperty(r,"baseURI",{value:t});var o=r.createElement("meta");return o.setAttribute("charset","utf-8"),r.head.appendChild(o),r.head.appendChild(n),r. body.innerHTML=e,window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTML TemplateElement.bootstrap(r),r}var o=e.flags,i=e.IMPORT_LINK_TYPE,a=e.IMPORT_SEL ECTOR,s=e.rootDocument,d=e.Loader,c=e.Observer,u=e.parser,l={documents:{},docume ntPreloadSelectors:a,importsPreloadSelectors:[a].join(","),loadNode:function(e){ h.addNode(e)},loadSubtree:function(e){var t=this.marshalNodes(e);h.addNodes(t)}, marshalNodes:function(e){return e.querySelectorAll(this.loadSelectorsForNode(e)) },loadSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?this.do cumentPreloadSelectors: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.bootDocu ment(d)),this.documents[e]=d),r["import"]=d}u.parseNext()},bootDocument:function (e){this.loadSubtree(e),this.observer.observe(e),u.parseNext()},loadedAll:functi on(){u.parseNext()}},h=new d(l.loaded.bind(l),l.loadedAll.bind(l));if(l.observer =new c,!document.baseURI){var m={get:function(){var e=document.querySelector("ba se");return e?e.href:window.location.href},configurable:!0};Object.definePropert y(document,"baseURI",m),Object.defineProperty(s,"baseURI",m)}e.importer=l,e.impo rtLoader=h}),HTMLImports.addModule(function(e){var t=e.parser,r=e.importer,n={ad ded:function(e){for(var n,o,i,a,s=0,d=e.length;d>s&&(a=e[s]);s++)n||(n=a.ownerDo cument,o=t.isParsed(n)),i=this.shouldLoadNode(a),i&&r.loadNode(a),this.shouldPar seNode(a)&&o&&t.parseDynamic(a,i)},shouldLoadNode:function(e){return 1===e.nodeT ype&&o.call(e,r.loadSelectorsForNode(e))},shouldParseNode:function(e){return 1== =e.nodeType&&o.call(e,t.parseSelectorsForNode(e))}};r.observer.addCallback=n.add ed.bind(n);var o=HTMLElement.prototype.matches||HTMLElement.prototype.matchesSel ector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMat chesSelector||HTMLElement.prototype.msMatchesSelector}),function(e){function t() {HTMLImports.importer.bootDocument(o)}var r=e.initializeModules,n=e.isIE;if(!e.u seNative){n&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function (e,t){t=t||{};var r=document.createEvent("CustomEvent");return r.initCustomEvent (e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),r},window.CustomEvent.prot otype=window.Event.prototype),r();var o=e.rootDocument;"complete"===document.rea dyState||"interactive"===document.readyState&&!window.attachEvent?t():document.a ddEventListener("DOMContentLoaded",t)}}(HTMLImports);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698