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

Side by Side Diff: pkg/html_import/lib/html_import.min.js

Issue 158083002: introduce web_components pkg for consolidated polyfills (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/html_import/lib/html_import.debug.js ('k') | pkg/html_import/lib/src/HTMLImports.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Polymer Authors. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 !function(){function a(){HTMLImports.importer.load(document,function(){HTMLImpor ts.parser.parse(document),HTMLImports.readyTime=(new Date).getTime(),document.di spatchEvent(new CustomEvent("HTMLImportsLoaded",{bubbles:!0}))})}"function"!=typ eof window.CustomEvent&&(window.CustomEvent=function(a){var b=document.createEve nt("HTMLEvents");return b.initEvent(a,!0,!0),b}),"complete"===document.readyStat e?a():window.addEventListener("DOMContentLoaded",a)}(),function(a){function b(a) {return d(a,i)}function c(a){return d(a,j)}function d(a,b){return"link"===a.loca lName&&a.getAttribute("rel")===b}function e(a){return"script"===a.localName}func tion f(a,b){var c=a;c instanceof Document||(c=document.implementation.createHTML Document(i),c.body.innerHTML=a),c._URL=b;var d=c.createElement("base");return d. setAttribute("href",document.baseURI),c.head.appendChild(d),window.HTMLTemplateE lement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(c),c}a||(a= window.HTMLImports={flags:{}});var g,h=a.xhr,i="import",j="stylesheet",k={docume nts:{},cache:{},preloadSelectors:["link[rel="+i+"]","element link[rel="+j+"]","t emplate","script[src]:not([type])",'script[src][type="text/javascript"]'].join(" ,"),loader:function(a){return g=new l(k.loaded,a),g.cache=k.cache,g},load:functi on(a,b){g=k.loader(b),k.preload(a)},preload:function(a){var b=a.querySelectorAll (k.preloadSelectors);b=this.filterMainDocumentNodes(a,b),b=this.extractTemplateN odes(b),g.addNodes(b)},filterMainDocumentNodes:function(a,b){return a===document &&(b=Array.prototype.filter.call(b,function(a){return!e(a)})),b},extractTemplate Nodes:function(a){var b=[];return a=Array.prototype.filter.call(a,function(a){if ("template"===a.localName){if(a.content){var c=a.content.querySelectorAll("link[ rel="+j+"]");c.length&&(b=b.concat(Array.prototype.slice.call(c,0)))}return!1}re turn!0}),b.length&&(a=a.concat(b)),a},loaded:function(a,d,e){if(b(d)){var g=k.do cuments[a];g||(g=f(e,a),p.resolvePathsInHTML(g),k.documents[a]=g,k.preload(g)),d .import={href:a,ownerNode:d,content:g},d.content=e=g}d.__resource=e,c(d)&&p.reso lvePathsInStylesheet(d)}},l=function(a,b){this.onload=a,this.oncomplete=b,this.i nflight=0,this.pending={},this.cache={}};l.prototype={addNodes:function(a){this. inflight+=a.length,q(a,this.require,this),this.checkDone()},require:function(a){ var b=p.nodeUrl(a);a.__nodeUrl=b,this.dedupe(b,a)||this.fetch(b,a)},dedupe:funct ion(a,b){return this.pending[a]?(this.pending[a].push(b),!0):this.cache[a]?(this .onload(a,b,g.cache[a]),this.tail(),!0):(this.pending[a]=[b],!1)},fetch:function (a,b){var c=function(c,d){this.receive(a,b,c,d)}.bind(this);h.load(a,c)},receive :function(a,b,c,d){c||(g.cache[a]=d),g.pending[a].forEach(function(b){c||this.on load(a,b,d),this.tail()},this),g.pending[a]=null},tail:function(){--this.infligh t,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}};var m=["href","src","action"],n="["+m.join("],[")+"]",o="{{.*}}",p={nodeUrl:function (a){return p.resolveUrl(p.getDocumentUrl(document),p.hrefOrSrc(a))},hrefOrSrc:fu nction(a){return a.getAttribute("href")||a.getAttribute("src")},documentUrlFromN ode:function(a){return p.getDocumentUrl(a.ownerDocument||a)},getDocumentUrl:func tion(a){var b=a&&(a._URL||a.impl&&a.impl._URL||a.baseURI||a.URL)||"";return b.sp lit("#")[0]},resolveUrl:function(a,b,c){if(this.isAbsUrl(b))return b;var d=this. compressUrl(this.urlToPath(a)+b);return c&&(d=p.makeRelPath(p.getDocumentUrl(doc ument),d)),d},isAbsUrl:function(a){return/(^data:)|(^http[s]?:)|(^\/)/.test(a)}, urlToPath:function(a){var b=a.split("/");return b.pop(),b.push(""),b.join("/")}, compressUrl:function(a){for(var b,c=a.split("/"),d=0;d<c.length;d++)b=c[d],".."= ==b&&(c.splice(d-1,2),d-=2);return c.join("/")},makeRelPath:function(a,b){var c, d;for(c=this.compressUrl(a).split("/"),d=this.compressUrl(b).split("/");c.length &&c[0]===d[0];)c.shift(),d.shift();for(var e=0,f=c.length-1;f>e;e++)d.unshift(". .");var g=d.join("/");return g},resolvePathsInHTML:function(a,b){b=b||p.document UrlFromNode(a),p.resolveAttributes(a,b),p.resolveStyleElts(a,b);var c=a.querySel ectorAll("template");c&&q(c,function(a){a.content&&p.resolvePathsInHTML(a.conten t,b)})},resolvePathsInStylesheet:function(a){var b=p.nodeUrl(a);a.__resource=p.r esolveCssText(a.__resource,b)},resolveStyleElts:function(a,b){var c=a.querySelec torAll("style");c&&q(c,function(a){a.textContent=p.resolveCssText(a.textContent, b)})},resolveCssText:function(a,b){return a.replace(/url\([^)]*\)/g,function(a){ var c=a.replace(/["']/g,"").slice(4,-1);return c=p.resolveUrl(b,c,!0),"url("+c+" )"})},resolveAttributes:function(a,b){var c=a&&a.querySelectorAll(n);c&&q(c,func tion(a){this.resolveNodeAttributes(a,b)},this)},resolveNodeAttributes:function(a ,b){m.forEach(function(c){var d=a.attributes[c];if(d&&d.value&&d.value.search(o) <0){var e=p.resolveUrl(b,d.value,!0);d.value=e}})}};h=h||{async:!0,ok:function(a ){return a.status>=200&&a.status<300||304===a.status||0===a.status},load:functio n(b,c,d){var e=new XMLHttpRequest;return(a.flags.debug||a.flags.bust)&&(b+="?"+M ath.random()),e.open("GET",b,h.async),e.addEventListener("readystatechange",func tion(){4===e.readyState&&c.call(d,!h.ok(e)&&e,e.response,b)}),e.send(),e},loadDo cument:function(a,b,c){this.load(a,b,c).responseType="document"}};var q=Array.pr ototype.forEach.call.bind(Array.prototype.forEach);a.path=p,a.xhr=h,a.importer=k ,a.getDocumentUrl=p.getDocumentUrl,a.IMPORT_LINK_TYPE=i}(window.HTMLImports),fun ction(a){function b(a){return"link"===a.localName&&a.getAttribute("rel")===f}fun ction c(a){return a.parentNode&&!d(a)&&!e(a)}function d(a){return a.ownerDocumen t===document||a.ownerDocument.impl===document}function e(a){return a.parentNode& &"element"===a.parentNode.localName}var f="import",g={selectors:["link[rel="+f+" ]","link[rel=stylesheet]","style","script:not([type])",'script[type="text/javasc ript"]'],map:{link:"parseLink",script:"parseScript",style:"parseGeneric"},parse: function(a){if(!a.__importParsed){a.__importParsed=!0;var b=a.querySelectorAll(g .selectors);h(b,function(a){g[g.map[a.localName]](a)})}},parseLink:function(a){b (a)?a.content&&g.parse(a.content):this.parseGeneric(a)},parseGeneric:function(a) {c(a)&&document.head.appendChild(a)},parseScript:function(b){if(c(b)){var d=(b._ _resource||b.textContent).trim();if(d){var e=b.__nodeUrl;if(!e){var e=a.path.doc umentUrlFromNode(b),f="["+Math.floor(1e3*(Math.random()+1))+"]",g=d.match(/Polym er\(['"]([^'"]*)/);f=g&&g[1]||f,e+="/"+f+".js"}d+="\n//# sourceURL="+e+"\n",eval .call(window,d)}}}},h=Array.prototype.forEach.call.bind(Array.prototype.forEach) ;a.parser=g}(HTMLImports);
OLDNEW
« no previous file with comments | « pkg/html_import/lib/html_import.debug.js ('k') | pkg/html_import/lib/src/HTMLImports.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698