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

Side by Side Diff: pkg/custom_element/lib/custom-elements.min.js

Issue 112433002: update our CustomElement+Shadow DOM patch (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/custom_element/lib/custom-elements.debug.js ('k') | pkg/custom_element/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. 1 // Copyright (c) 2012 The Polymer Authors. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer 10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the 11 // in the documentation and/or other materials provided with the
12 // distribution. 12 // distribution.
13 // * Neither the name of Google Inc. nor the names of its 13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from 14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission. 15 // this software without specific prior written permission.
16 // 16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 "undefined"==typeof WeakMap&&!function(){var a=Object.defineProperty,b=Date.now( )%1e9,c=function(){this.name="__st"+(1e9*Math.random()>>>0)+(b++ +"__")};c.proto type={set:function(b,c){var d=b[this.name];d&&d[0]===b?d[1]=c:a(b,this.name,{val ue:[b,c],writable:!0})},get:function(a){var b;return(b=a[this.name])&&b[0]===a?b [1]:void 0},"delete":function(a){this.set(a,void 0)}},window.WeakMap=c}(),functi on(a){function b(a){u.push(a),t||(t=!0,q(d))}function c(a){return window.ShadowD OMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(a)||a}function d(){t=!1;var a= u;u=[],a.sort(function(a,b){return a.uid_-b.uid_});var b=!1;a.forEach(function(a ){var c=a.takeRecords();e(a),c.length&&(a.callback_(c,a),b=!0)}),b&&d()}function e(a){a.nodes_.forEach(function(b){var c=p.get(b);c&&c.forEach(function(b){b.obs erver===a&&b.removeTransientObservers()})})}function f(a,b){for(var c=a;c;c=c.pa rentNode){var d=p.get(c);if(d)for(var e=0;e<d.length;e++){var f=d[e],g=f.options ;if(c===a||g.subtree){var h=b(g);h&&f.enqueue(h)}}}}function g(a){this.callback_ =a,this.nodes_=[],this.records_=[],this.uid_=++v}function h(a,b){this.type=a,thi s.target=b,this.addedNodes=[],this.removedNodes=[],this.previousSibling=null,thi s.nextSibling=null,this.attributeName=null,this.attributeNamespace=null,this.old Value=null}function i(a){var b=new h(a.type,a.target);return b.addedNodes=a.adde dNodes.slice(),b.removedNodes=a.removedNodes.slice(),b.previousSibling=a.previou sSibling,b.nextSibling=a.nextSibling,b.attributeName=a.attributeName,b.attribute Namespace=a.attributeNamespace,b.oldValue=a.oldValue,b}function j(a,b){return w= new h(a,b)}function k(a){return x?x:(x=i(w),x.oldValue=a,x)}function l(){w=x=voi d 0}function m(a){return a===x||a===w}function n(a,b){return a===b?a:x&&m(a)?x:n ull}function o(a,b,c){this.observer=a,this.target=b,this.options=c,this.transien tObservedNodes=[]}var p=new WeakMap,q=window.msSetImmediate;if(!q){var r=[],s=St ring(Math.random());window.addEventListener("message",function(a){if(a.data===s) {var b=r;r=[],b.forEach(function(a){a()})}}),q=function(a){r.push(a),window.post Message(s,"*")}}var t=!1,u=[],v=0;g.prototype={observe:function(a,b){if(a=c(a),! b.childList&&!b.attributes&&!b.characterData||b.attributeOldValue&&!b.attributes ||b.attributeFilter&&b.attributeFilter.length&&!b.attributes||b.characterDataOld Value&&!b.characterData)throw new SyntaxError;var d=p.get(a);d||p.set(a,d=[]);fo r(var e,f=0;f<d.length;f++)if(d[f].observer===this){e=d[f],e.removeListeners(),e .options=b;break}e||(e=new o(this,a,b),d.push(e),this.nodes_.push(a)),e.addListe ners()},disconnect:function(){this.nodes_.forEach(function(a){for(var b=p.get(a) ,c=0;c<b.length;c++){var d=b[c];if(d.observer===this){d.removeListeners(),b.spli ce(c,1);break}}},this),this.records_=[]},takeRecords:function(){var a=this.recor ds_;return this.records_=[],a}};var w,x;o.prototype={enqueue:function(a){var c=t his.observer.records_,d=c.length;if(c.length>0){var e=c[d-1],f=n(e,a);if(f)retur n c[d-1]=f,void 0}else b(this.observer);c[d]=a},addListeners:function(){this.add Listeners_(this.target)},addListeners_:function(a){var b=this.options;b.attribut es&&a.addEventListener("DOMAttrModified",this,!0),b.characterData&&a.addEventLis tener("DOMCharacterDataModified",this,!0),b.childList&&a.addEventListener("DOMNo deInserted",this,!0),(b.childList||b.subtree)&&a.addEventListener("DOMNodeRemove d",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},remo veListeners_:function(a){var b=this.options;b.attributes&&a.removeEventListener( "DOMAttrModified",this,!0),b.characterData&&a.removeEventListener("DOMCharacterD ataModified",this,!0),b.childList&&a.removeEventListener("DOMNodeInserted",this, !0),(b.childList||b.subtree)&&a.removeEventListener("DOMNodeRemoved",this,!0)},a ddTransientObserver:function(a){if(a!==this.target){this.addListeners_(a),this.t ransientObservedNodes.push(a);var b=p.get(a);b||p.set(a,b=[]),b.push(this)}},rem oveTransientObservers:function(){var a=this.transientObservedNodes;this.transien tObservedNodes=[],a.forEach(function(a){this.removeListeners_(a);for(var b=p.get (a),c=0;c<b.length;c++)if(b[c]===this){b.splice(c,1);break}},this)},handleEvent: function(a){switch(a.stopImmediatePropagation(),a.type){case"DOMAttrModified":va r b=a.attrName,c=a.relatedNode.namespaceURI,d=a.target,e=new j("attributes",d);e .attributeName=b,e.attributeNamespace=c;var g=a.attrChange===MutationEvent.ADDIT ION?null:a.prevValue;f(d,function(a){return!a.attributes||a.attributeFilter&&a.a ttributeFilter.length&&-1===a.attributeFilter.indexOf(b)&&-1===a.attributeFilter .indexOf(c)?void 0:a.attributeOldValue?k(g):e});break;case"DOMCharacterDataModif ied":var d=a.target,e=j("characterData",d),g=a.prevValue;f(d,function(a){return a.characterData?a.characterDataOldValue?k(g):e:void 0});break;case"DOMNodeRemove d":this.addTransientObserver(a.target);case"DOMNodeInserted":var h,i,d=a.related Node,m=a.target;"DOMNodeInserted"===a.type?(h=[m],i=[]):(h=[],i=[m]);var n=m.pre viousSibling,o=m.nextSibling,e=j("childList",d);e.addedNodes=h,e.removedNodes=i, e.previousSibling=n,e.nextSibling=o,f(d,function(a){return a.childList?e:void 0} )}l()}},a.JsMutationObserver=g,!a.MutationObserver&&a.WebKitMutationObserver&&(a .MutationObserver=a.WebKitMutationObserver),a.MutationObserver||(a.MutationObser ver=g)}(this),window.CustomElements=window.CustomElements||{flags:{}},function(a ){function b(a,c,d){var e=a.firstElementChild;if(!e)for(e=a.firstChild;e&&e.node Type!==Node.ELEMENT_NODE;)e=e.nextSibling;for(;e;)c(e,d)!==!0&&b(e,c,d),e=e.next ElementSibling;return null}function c(a,b){for(var c=a.shadowRoot;c;)d(c,b),c=c. olderShadowRoot}function d(a,d){b(a,function(a){return d(a)?!0:(c(a,d),void 0)}) ,c(a,d)}function e(a){return h(a)?(i(a),!0):(l(a),void 0)}function f(a){d(a,func tion(a){return e(a)?!0:void 0})}function g(a){return e(a)||f(a)}function h(b){if (!b.__upgraded__&&b.nodeType===Node.ELEMENT_NODE){var c=b.getAttribute("is")||b. localName,d=a.registry[c];if(d)return y.dom&&console.group("upgrade:",b.localNam e),a.upgrade(b),y.dom&&console.groupEnd(),!0}}function i(a){l(a),q(a)&&d(a,funct ion(a){l(a)})}function j(a){if(B.push(a),!A){A=!0;var b=window.Platform&&window. Platform.endOfMicrotask||setTimeout;b(k)}}function k(){A=!1;for(var a,b=B,c=0,d= b.length;d>c&&(a=b[c]);c++)a();B=[]}function l(a){z?j(function(){m(a)}):m(a)}fun ction m(a){(a.enteredViewCallback||a.__upgraded__&&y.dom)&&(y.dom&&console.group ("inserted:",a.localName),q(a)&&(a.__inserted=(a.__inserted||0)+1,a.__inserted<1 &&(a.__inserted=1),a.__inserted>1?y.dom&&console.warn("inserted:",a.localName,"i nsert/remove count:",a.__inserted):a.enteredViewCallback&&(y.dom&&console.log("i nserted:",a.localName),a.enteredViewCallback())),y.dom&&console.groupEnd())}func tion n(a){o(a),d(a,function(a){o(a)})}function o(a){z?j(function(){p(a)}):p(a)}f unction p(a){(a.leftViewCallback||a.__upgraded__&&y.dom)&&(y.dom&&console.log("r emoved:",a.localName),q(a)||(a.__inserted=(a.__inserted||0)-1,a.__inserted>0&&(a .__inserted=0),a.__inserted<0?y.dom&&console.warn("removed:",a.localName,"insert /remove count:",a.__inserted):a.leftViewCallback&&a.leftViewCallback()))}functio n q(a){for(var b=a,c=window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNe eded(document)||document;b;){if(b==c)return!0;b=b.parentNode||b.host}}function r (a){if(a.shadowRoot&&!a.shadowRoot.__watched){y.dom&&console.log("watching shado w-root for: ",a.localName);for(var b=a.shadowRoot;b;)s(b),b=b.olderShadowRoot}}f unction s(a){a.__watched||(v(a),a.__watched=!0)}function t(a){if(y.dom){var b=a[ 0];if(b&&"childList"===b.type&&b.addedNodes&&b.addedNodes){for(var c=b.addedNode s[0];c&&c!==document&&!c.host;)c=c.parentNode;var d=c&&(c.URL||c._URL||c.host&&c .host.localName)||"";d=d.split("/?").shift().split("/").pop()}console.group("mut ations (%d) [%s]",a.length,d||"")}a.forEach(function(a){"childList"===a.type&&(D (a.addedNodes,function(a){a.localName&&g(a)}),D(a.removedNodes,function(a){a.loc alName&&n(a)}))}),y.dom&&console.groupEnd()}function u(){t(C.takeRecords()),k()} function v(a){C.observe(a,{childList:!0,subtree:!0})}function w(a){v(a)}function x(a){y.dom&&console.group("upgradeDocument: ",(a.URL||a._URL||"").split("/").po p()),g(a),y.dom&&console.groupEnd()}var y=window.logFlags||{},z=!window.Mutation Observer||window.MutationObserver===window.JsMutationObserver;a.hasPolyfillMutat ions=z;var A=!1,B=[],C=new MutationObserver(t),D=Array.prototype.forEach.call.bi nd(Array.prototype.forEach);a.watchShadow=r,a.upgradeAll=g,a.upgradeSubtree=f,a. observeDocument=w,a.upgradeDocument=x,a.takeRecords=u}(window.CustomElements),fu nction(a){function b(b,f){var g=f||{};if(!b)throw new Error("document.register: first argument `name` must not be empty");if(b.indexOf("-")<0)throw new Error("d ocument.register: first argument ('name') must contain a dash ('-'). Argument pr ovided was '"+String(b)+"'.");if(m(b))throw new Error("DuplicateDefinitionError: a type with name '"+String(b)+"' is already registered");if(!g.prototype)throw new Error("Options missing required prototype property");return g.name=b.toLower Case(),g.lifecycle=g.lifecycle||{},g.ancestry=c(g.extends),d(g),e(g),k(g.prototy pe),n(g.name,g),g.ctor=o(g),g.ctor.prototype=g.prototype,g.prototype.constructor =g.ctor,(a.ready||a.performedInitialDocumentUpgrade)&&a.upgradeAll(document),g.c tor}function c(a){var b=m(a);return b?c(b.extends).concat([b]):[]}function d(a){ for(var b,c=a.extends,d=0;b=a.ancestry[d];d++)c=b.is&&b.tag;a.tag=c||a.name,c&&( a.is=a.name)}function e(a){if(!Object.__proto__){var b=HTMLElement.prototype;if( a.is){var c=document.createElement(a.tag);b=Object.getPrototypeOf(c)}for(var d,e =a.prototype;e&&e!==b;){var d=Object.getPrototypeOf(e);e.__proto__=d,e=d}}a.nati ve=b}function f(a){return g(x(a.tag),a)}function g(b,c){return c.is&&b.setAttrib ute("is",c.is),b.removeAttribute("unresolved"),h(b,c),b.__upgraded__=!0,a.upgrad eSubtree(b),j(b),b}function h(a,b){Object.__proto__?a.__proto__=b.prototype:(i(a ,b.prototype,b.native),a.__proto__=b.prototype)}function i(a,b,c){for(var d={},e =b;e!==c&&e!==HTMLUnknownElement.prototype;){for(var f,g=Object.getOwnPropertyNa mes(e),h=0;f=g[h];h++)d[f]||(Object.defineProperty(a,f,Object.getOwnPropertyDesc riptor(e,f)),d[f]=1);e=Object.getPrototypeOf(e)}}function j(a){a.createdCallback &&a.createdCallback()}function k(a){if(!a.setAttribute._polyfilled){var b=a.setA ttribute;a.setAttribute=function(a,c){l.call(this,a,c,b)};var c=a.removeAttribut e;a.removeAttribute=function(a){l.call(this,a,null,c)},a.setAttribute._polyfille d=!0}}function l(a,b,c){var d=this.getAttribute(a);c.apply(this,arguments);var e =this.getAttribute(a);this.attributeChangedCallback&&e!==d&&this.attributeChange dCallback(a,d,e)}function m(a){return a?w[a.toLowerCase()]:void 0}function n(a,b ){if(w[a])throw new Error("a type with that name is already registered.");w[a]=b }function o(a){return function(){return f(a)}}function p(a,b){var c=m(b||a);if(c ){if(a==c.tag&&b==c.is)return new c.ctor;if(!b&&!c.is)return new c.ctor}if(b){va r d=p(a);return d.setAttribute("is",b),d}var d=x(a);return a.indexOf("-")>=0&&h( d,HTMLElement),d}function q(a){if(!a.__upgraded__&&a.nodeType===Node.ELEMENT_NOD E){var b=a.getAttribute("is"),c=w[b||a.localName];if(c){if(b&&c.tag==a.localName )return g(a,c);if(!b&&!c.extends)return g(a,c)}}}function r(b){var c=y.call(this ,b);return a.upgradeAll(c),c}a||(a=window.CustomElements={flags:{}});var s=a.fla gs,t=Boolean(document.register),u=!s.register&&t;if(u){var v=function(){};a.regi stry={},a.upgradeElement=v,a.watchShadow=v,a.upgrade=v,a.upgradeAll=v,a.upgradeS ubtree=v,a.observeDocument=v,a.upgradeDocument=v,a.takeRecords=v}else{var w={},x =document.createElement.bind(document),y=Node.prototype.cloneNode;document.regis ter=b,document.createElement=p,Node.prototype.cloneNode=r,a.registry=w,a.upgrade =q}a.hasNative=t,a.useNative=u}(window.CustomElements),function(){function a(a){ return"link"===a.localName&&a.getAttribute("rel")===b}var b=window.HTMLImports?H TMLImports.IMPORT_LINK_TYPE:"none",c={selectors:["link[rel="+b+"]"],map:{link:"p arseLink"},parse:function(a){if(!a.__parsed){a.__parsed=!0;var b=a.querySelector All(c.selectors);d(b,function(a){c[c.map[a.localName]](a)}),CustomElements.upgra deDocument(a),CustomElements.observeDocument(a)}},parseLink:function(b){a(b)&&th is.parseImport(b)},parseImport:function(a){a.content&&c.parse(a.content)}},d=Arr ay.prototype.forEach.call.bind(Array.prototype.forEach);CustomElements.parser=c} (),function(a){function b(){CustomElements.parser.parse(document),CustomElements .upgradeDocument(document),CustomElements.performedInitialDocumentUpgrade=!0;var a=window.Platform&&Platform.endOfMicrotask?Platform.endOfMicrotask:setTimeout;a (function(){CustomElements.ready=!0,CustomElements.readyTime=Date.now(),window.H TMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTi me),document.body.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0 }))})}if("function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a){ var b=document.createEvent("HTMLEvents");return b.initEvent(a,!0,!0),b}),"comple te"===document.readyState||a.flags.eager)b();else if("interactive"!==document.re adyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var c=window.HTMLImports?"HTMLImportsLoaded":"loading"==document.readyState?"DOMCon tentLoaded":"load";window.addEventListener(c,b)}else b()}(window.CustomElements) ,function(){if(HTMLElement.prototype.createShadowRoot){var a=HTMLElement.prototy pe.createShadowRoot;HTMLElement.prototype.createShadowRoot=function(){var b=a.ca ll(this);return b.host=this,b}}if(window.ShadowDOMPolyfill){var b=["upgradeAll", "upgradeSubtree","observeDocument","upgradeDocument"],c={};b.forEach(function(a) {c[a]=CustomElements[a]}),b.forEach(function(a){CustomElements[a]=function(b){re turn c[a](window.ShadowDOMPolyfill.wrapIfNeeded(b))}})}if(window.CustomElements& &!CustomElements.useNative){var d=Document.prototype.importNode;Document.prototy pe.importNode=function(a,b){var c=d.call(this,a,b);return CustomElements.upgrade All(c),c}}}(); 28 "undefined"==typeof WeakMap&&!function(){var a=Object.defineProperty,b=Date.now( )%1e9,c=function(){this.name="__st"+(1e9*Math.random()>>>0)+(b++ +"__")};c.proto type={set:function(b,c){var d=b[this.name];d&&d[0]===b?d[1]=c:a(b,this.name,{val ue:[b,c],writable:!0})},get:function(a){var b;return(b=a[this.name])&&b[0]===a?b [1]:void 0},"delete":function(a){this.set(a,void 0)}},window.WeakMap=c}(),functi on(a){function b(a){u.push(a),t||(t=!0,q(d))}function c(a){return window.ShadowD OMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(a)||a}function d(){t=!1;var a= u;u=[],a.sort(function(a,b){return a.uid_-b.uid_});var b=!1;a.forEach(function(a ){var c=a.takeRecords();e(a),c.length&&(a.callback_(c,a),b=!0)}),b&&d()}function e(a){a.nodes_.forEach(function(b){var c=p.get(b);c&&c.forEach(function(b){b.obs erver===a&&b.removeTransientObservers()})})}function f(a,b){for(var c=a;c;c=c.pa rentNode){var d=p.get(c);if(d)for(var e=0;e<d.length;e++){var f=d[e],g=f.options ;if(c===a||g.subtree){var h=b(g);h&&f.enqueue(h)}}}}function g(a){this.callback_ =a,this.nodes_=[],this.records_=[],this.uid_=++v}function h(a,b){this.type=a,thi s.target=b,this.addedNodes=[],this.removedNodes=[],this.previousSibling=null,thi s.nextSibling=null,this.attributeName=null,this.attributeNamespace=null,this.old Value=null}function i(a){var b=new h(a.type,a.target);return b.addedNodes=a.adde dNodes.slice(),b.removedNodes=a.removedNodes.slice(),b.previousSibling=a.previou sSibling,b.nextSibling=a.nextSibling,b.attributeName=a.attributeName,b.attribute Namespace=a.attributeNamespace,b.oldValue=a.oldValue,b}function j(a,b){return w= new h(a,b)}function k(a){return x?x:(x=i(w),x.oldValue=a,x)}function l(){w=x=voi d 0}function m(a){return a===x||a===w}function n(a,b){return a===b?a:x&&m(a)?x:n ull}function o(a,b,c){this.observer=a,this.target=b,this.options=c,this.transien tObservedNodes=[]}var p=new WeakMap,q=window.msSetImmediate;if(!q){var r=[],s=St ring(Math.random());window.addEventListener("message",function(a){if(a.data===s) {var b=r;r=[],b.forEach(function(a){a()})}}),q=function(a){r.push(a),window.post Message(s,"*")}}var t=!1,u=[],v=0;g.prototype={observe:function(a,b){if(a=c(a),! b.childList&&!b.attributes&&!b.characterData||b.attributeOldValue&&!b.attributes ||b.attributeFilter&&b.attributeFilter.length&&!b.attributes||b.characterDataOld Value&&!b.characterData)throw new SyntaxError;var d=p.get(a);d||p.set(a,d=[]);fo r(var e,f=0;f<d.length;f++)if(d[f].observer===this){e=d[f],e.removeListeners(),e .options=b;break}e||(e=new o(this,a,b),d.push(e),this.nodes_.push(a)),e.addListe ners()},disconnect:function(){this.nodes_.forEach(function(a){for(var b=p.get(a) ,c=0;c<b.length;c++){var d=b[c];if(d.observer===this){d.removeListeners(),b.spli ce(c,1);break}}},this),this.records_=[]},takeRecords:function(){var a=this.recor ds_;return this.records_=[],a}};var w,x;o.prototype={enqueue:function(a){var c=t his.observer.records_,d=c.length;if(c.length>0){var e=c[d-1],f=n(e,a);if(f)retur n c[d-1]=f,void 0}else b(this.observer);c[d]=a},addListeners:function(){this.add Listeners_(this.target)},addListeners_:function(a){var b=this.options;b.attribut es&&a.addEventListener("DOMAttrModified",this,!0),b.characterData&&a.addEventLis tener("DOMCharacterDataModified",this,!0),b.childList&&a.addEventListener("DOMNo deInserted",this,!0),(b.childList||b.subtree)&&a.addEventListener("DOMNodeRemove d",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},remo veListeners_:function(a){var b=this.options;b.attributes&&a.removeEventListener( "DOMAttrModified",this,!0),b.characterData&&a.removeEventListener("DOMCharacterD ataModified",this,!0),b.childList&&a.removeEventListener("DOMNodeInserted",this, !0),(b.childList||b.subtree)&&a.removeEventListener("DOMNodeRemoved",this,!0)},a ddTransientObserver:function(a){if(a!==this.target){this.addListeners_(a),this.t ransientObservedNodes.push(a);var b=p.get(a);b||p.set(a,b=[]),b.push(this)}},rem oveTransientObservers:function(){var a=this.transientObservedNodes;this.transien tObservedNodes=[],a.forEach(function(a){this.removeListeners_(a);for(var b=p.get (a),c=0;c<b.length;c++)if(b[c]===this){b.splice(c,1);break}},this)},handleEvent: function(a){switch(a.stopImmediatePropagation(),a.type){case"DOMAttrModified":va r b=a.attrName,c=a.relatedNode.namespaceURI,d=a.target,e=new j("attributes",d);e .attributeName=b,e.attributeNamespace=c;var g=a.attrChange===MutationEvent.ADDIT ION?null:a.prevValue;f(d,function(a){return!a.attributes||a.attributeFilter&&a.a ttributeFilter.length&&-1===a.attributeFilter.indexOf(b)&&-1===a.attributeFilter .indexOf(c)?void 0:a.attributeOldValue?k(g):e});break;case"DOMCharacterDataModif ied":var d=a.target,e=j("characterData",d),g=a.prevValue;f(d,function(a){return a.characterData?a.characterDataOldValue?k(g):e:void 0});break;case"DOMNodeRemove d":this.addTransientObserver(a.target);case"DOMNodeInserted":var h,i,d=a.related Node,m=a.target;"DOMNodeInserted"===a.type?(h=[m],i=[]):(h=[],i=[m]);var n=m.pre viousSibling,o=m.nextSibling,e=j("childList",d);e.addedNodes=h,e.removedNodes=i, e.previousSibling=n,e.nextSibling=o,f(d,function(a){return a.childList?e:void 0} )}l()}},a.JsMutationObserver=g,!a.MutationObserver&&a.WebKitMutationObserver&&(a .MutationObserver=a.WebKitMutationObserver),a.MutationObserver||(a.MutationObser ver=g)}(this),window.CustomElements=window.CustomElements||{flags:{}},function(a ){function b(a,c,d){var e=a.firstElementChild;if(!e)for(e=a.firstChild;e&&e.node Type!==Node.ELEMENT_NODE;)e=e.nextSibling;for(;e;)c(e,d)!==!0&&b(e,c,d),e=e.next ElementSibling;return null}function c(a,b){for(var c=a.shadowRoot;c;)d(c,b),c=c. olderShadowRoot}function d(a,d){b(a,function(a){return d(a)?!0:(c(a,d),void 0)}) ,c(a,d)}function e(a){return h(a)?(i(a),!0):(l(a),void 0)}function f(a){d(a,func tion(a){return e(a)?!0:void 0})}function g(a){return e(a)||f(a)}function h(b){if (!b.__upgraded__&&b.nodeType===Node.ELEMENT_NODE){var c=b.getAttribute("is")||b. localName,d=a.registry[c];if(d)return y.dom&&console.group("upgrade:",b.localNam e),a.upgrade(b),y.dom&&console.groupEnd(),!0}}function i(a){l(a),q(a)&&d(a,funct ion(a){l(a)})}function j(a){if(B.push(a),!A){A=!0;var b=window.Platform&&window. Platform.endOfMicrotask||setTimeout;b(k)}}function k(){A=!1;for(var a,b=B,c=0,d= b.length;d>c&&(a=b[c]);c++)a();B=[]}function l(a){z?j(function(){m(a)}):m(a)}fun ction m(a){(a.enteredViewCallback||a.__upgraded__&&y.dom)&&(y.dom&&console.group ("inserted:",a.localName),q(a)&&(a.__inserted=(a.__inserted||0)+1,a.__inserted<1 &&(a.__inserted=1),a.__inserted>1?y.dom&&console.warn("inserted:",a.localName,"i nsert/remove count:",a.__inserted):a.enteredViewCallback&&(y.dom&&console.log("i nserted:",a.localName),a.enteredViewCallback())),y.dom&&console.groupEnd())}func tion n(a){o(a),d(a,function(a){o(a)})}function o(a){z?j(function(){p(a)}):p(a)}f unction p(a){(a.leftViewCallback||a.__upgraded__&&y.dom)&&(y.dom&&console.log("r emoved:",a.localName),q(a)||(a.__inserted=(a.__inserted||0)-1,a.__inserted>0&&(a .__inserted=0),a.__inserted<0?y.dom&&console.warn("removed:",a.localName,"insert /remove count:",a.__inserted):a.leftViewCallback&&a.leftViewCallback()))}functio n q(a){for(var b=a,c=window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNe eded(document)||document;b;){if(b==c)return!0;b=b.parentNode||b.host}}function r (a){if(a.shadowRoot&&!a.shadowRoot.__watched){y.dom&&console.log("watching shado w-root for: ",a.localName);for(var b=a.shadowRoot;b;)s(b),b=b.olderShadowRoot}}f unction s(a){a.__watched||(v(a),a.__watched=!0)}function t(a){if(y.dom){var b=a[ 0];if(b&&"childList"===b.type&&b.addedNodes&&b.addedNodes){for(var c=b.addedNode s[0];c&&c!==document&&!c.host;)c=c.parentNode;var d=c&&(c.URL||c._URL||c.host&&c .host.localName)||"";d=d.split("/?").shift().split("/").pop()}console.group("mut ations (%d) [%s]",a.length,d||"")}a.forEach(function(a){"childList"===a.type&&(D (a.addedNodes,function(a){a.localName&&g(a)}),D(a.removedNodes,function(a){a.loc alName&&n(a)}))}),y.dom&&console.groupEnd()}function u(){t(C.takeRecords()),k()} function v(a){C.observe(a,{childList:!0,subtree:!0})}function w(a){v(a)}function x(a){y.dom&&console.group("upgradeDocument: ",(a.URL||a._URL||"").split("/").po p()),g(a),y.dom&&console.groupEnd()}var y=window.logFlags||{},z=!window.Mutation Observer||window.MutationObserver===window.JsMutationObserver;a.hasPolyfillMutat ions=z;var A=!1,B=[],C=new MutationObserver(t),D=Array.prototype.forEach.call.bi nd(Array.prototype.forEach);a.watchShadow=r,a.upgradeAll=g,a.upgradeSubtree=f,a. observeDocument=w,a.upgradeDocument=x,a.takeRecords=u}(window.CustomElements),fu nction(a){function b(b,f){var g=f||{};if(!b)throw new Error("document.register: first argument `name` must not be empty");if(b.indexOf("-")<0)throw new Error("d ocument.register: first argument ('name') must contain a dash ('-'). Argument pr ovided was '"+String(b)+"'.");if(m(b))throw new Error("DuplicateDefinitionError: a type with name '"+String(b)+"' is already registered");if(!g.prototype)throw new Error("Options missing required prototype property");return g.name=b.toLower Case(),g.lifecycle=g.lifecycle||{},g.ancestry=c(g.extends),d(g),e(g),k(g.prototy pe),n(g.name,g),g.ctor=o(g),g.ctor.prototype=g.prototype,g.prototype.constructor =g.ctor,(a.ready||a.performedInitialDocumentUpgrade)&&a.upgradeAll(document),g.c tor}function c(a){var b=m(a);return b?c(b.extends).concat([b]):[]}function d(a){ for(var b,c=a.extends,d=0;b=a.ancestry[d];d++)c=b.is&&b.tag;a.tag=c||a.name,c&&( a.is=a.name)}function e(a){if(!Object.__proto__){var b=HTMLElement.prototype;if( a.is){var c=document.createElement(a.tag);b=Object.getPrototypeOf(c)}for(var d,e =a.prototype;e&&e!==b;){var d=Object.getPrototypeOf(e);e.__proto__=d,e=d}}a.nati ve=b}function f(a){return g(x(a.tag),a)}function g(b,c){return c.is&&b.setAttrib ute("is",c.is),b.removeAttribute("unresolved"),h(b,c),b.__upgraded__=!0,a.upgrad eSubtree(b),j(b),b}function h(a,b){Object.__proto__?a.__proto__=b.prototype:(i(a ,b.prototype,b.native),a.__proto__=b.prototype)}function i(a,b,c){for(var d={},e =b;e!==c&&e!==HTMLUnknownElement.prototype;){for(var f,g=Object.getOwnPropertyNa mes(e),h=0;f=g[h];h++)d[f]||(Object.defineProperty(a,f,Object.getOwnPropertyDesc riptor(e,f)),d[f]=1);e=Object.getPrototypeOf(e)}}function j(a){a.createdCallback &&a.createdCallback()}function k(a){if(!a.setAttribute._polyfilled){var b=a.setA ttribute;a.setAttribute=function(a,c){l.call(this,a,c,b)};var c=a.removeAttribut e;a.removeAttribute=function(a){l.call(this,a,null,c)},a.setAttribute._polyfille d=!0}}function l(a,b,c){var d=this.getAttribute(a);c.apply(this,arguments);var e =this.getAttribute(a);this.attributeChangedCallback&&e!==d&&this.attributeChange dCallback(a,d,e)}function m(a){return a?w[a.toLowerCase()]:void 0}function n(a,b ){if(w[a])throw new Error("a type with that name is already registered.");w[a]=b }function o(a){return function(){return f(a)}}function p(a,b){var c=m(b||a);if(c ){if(a==c.tag&&b==c.is)return new c.ctor;if(!b&&!c.is)return new c.ctor}if(b){va r d=p(a);return d.setAttribute("is",b),d}var d=x(a);return a.indexOf("-")>=0&&h( d,HTMLElement),d}function q(a){if(!a.__upgraded__&&a.nodeType===Node.ELEMENT_NOD E){var b=a.getAttribute("is"),c=w[b||a.localName];if(c){if(b&&c.tag==a.localName )return g(a,c);if(!b&&!c.extends)return g(a,c)}}}function r(b){var c=y.call(this ,b);return a.upgradeAll(c),c}a||(a=window.CustomElements={flags:{}});var s=a.fla gs,t=Boolean(document.register),u=!s.register&&t;if(u){var v=function(){};a.regi stry={},a.upgradeElement=v,a.watchShadow=v,a.upgrade=v,a.upgradeAll=v,a.upgradeS ubtree=v,a.observeDocument=v,a.upgradeDocument=v,a.takeRecords=v}else{var w={},x =document.createElement.bind(document),y=Node.prototype.cloneNode;document.regis ter=b,document.createElement=p,Node.prototype.cloneNode=r,a.registry=w,a.upgrade =q}a.hasNative=t,a.useNative=u}(window.CustomElements),function(){function a(a){ return"link"===a.localName&&a.getAttribute("rel")===b}var b=window.HTMLImports?H TMLImports.IMPORT_LINK_TYPE:"none",c={selectors:["link[rel="+b+"]"],map:{link:"p arseLink"},parse:function(a){if(!a.__parsed){a.__parsed=!0;var b=a.querySelector All(c.selectors);d(b,function(a){c[c.map[a.localName]](a)}),CustomElements.upgra deDocument(a),CustomElements.observeDocument(a)}},parseLink:function(b){a(b)&&th is.parseImport(b)},parseImport:function(a){a.content&&c.parse(a.content)}},d=Arr ay.prototype.forEach.call.bind(Array.prototype.forEach);CustomElements.parser=c} (),function(a){function b(){CustomElements.parser.parse(document),CustomElements .upgradeDocument(document),CustomElements.performedInitialDocumentUpgrade=!0;var a=window.Platform&&Platform.endOfMicrotask?Platform.endOfMicrotask:setTimeout;a (function(){CustomElements.ready=!0,CustomElements.readyTime=Date.now(),window.H TMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTi me),document.body.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0 }))})}if("function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a){ var b=document.createEvent("HTMLEvents");return b.initEvent(a,!0,!0),b}),"comple te"===document.readyState||a.flags.eager)b();else if("interactive"!==document.re adyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var c=window.HTMLImports?"HTMLImportsLoaded":"loading"==document.readyState?"DOMCon tentLoaded":"load";window.addEventListener(c,b)}else b()}(window.CustomElements) ,function(){if(HTMLElement.prototype.createShadowRoot){var a=HTMLElement.prototy pe.createShadowRoot;HTMLElement.prototype.createShadowRoot=function(){var b=a.ca ll(this);return b.host=this,CustomElements.watchShadow(this),b}}if(window.Shadow DOMPolyfill){var b=["upgradeAll","upgradeSubtree","observeDocument","upgradeDocu ment"],c={};b.forEach(function(a){c[a]=CustomElements[a]}),b.forEach(function(a) {CustomElements[a]=function(b){return c[a](window.ShadowDOMPolyfill.wrapIfNeeded (b))}})}if(window.CustomElements&&!CustomElements.useNative){var d=Document.prot otype.importNode;Document.prototype.importNode=function(a,b){var c=d.call(this,a ,b);return CustomElements.upgradeAll(c),c}}}();
OLDNEW
« no previous file with comments | « pkg/custom_element/lib/custom-elements.debug.js ('k') | pkg/custom_element/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698