@webcomponents/shadydom
Advanced tools
Comparing version 1.0.9 to 1.0.10
{ | ||
"name": "@webcomponents/shadydom", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Shadow DOM polyfill", | ||
@@ -43,6 +43,6 @@ "main": "shadydom.min.js", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-rollup": "^2.13.0", | ||
"gulp-rollup": "^2.15.0", | ||
"gulp-size": "^2.1.0", | ||
"gulp-sourcemaps": "^2.4.1", | ||
"web-component-tester": "^6.4.0" | ||
"web-component-tester": "^6.4.1" | ||
}, | ||
@@ -49,0 +49,0 @@ "publishConfig": { |
@@ -13,8 +13,8 @@ (function(){/* | ||
function ha(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c}function r(a,b){return{index:a,j:[],m:b}} | ||
function ia(a,b,c,d){var e=0,f=0,h=0,g=0,l=Math.min(b-e,d-f);if(0==e&&0==f)a:{for(h=0;h<l;h++)if(a[h]!==c[h])break a;h=l}if(b==a.length&&d==c.length){g=a.length;for(var k=c.length,m=0;m<l-h&&ja(a[--g],c[--k]);)m++;g=m}e+=h;f+=h;b-=g;d-=g;if(0==b-e&&0==d-f)return[];if(e==b){for(b=r(e,0);f<d;)b.j.push(c[f++]);return[b]}if(f==d)return[r(e,b-e)];l=e;h=f;d=d-h+1;g=b-l+1;b=Array(d);for(k=0;k<d;k++)b[k]=Array(g),b[k][0]=k;for(k=0;k<g;k++)b[0][k]=k;for(k=1;k<d;k++)for(m=1;m<g;m++)if(a[l+m-1]===c[h+k-1])b[k][m]= | ||
b[k-1][m-1];else{var q=b[k-1][m]+1,z=b[k][m-1]+1;b[k][m]=q<z?q:z}l=b.length-1;h=b[0].length-1;d=b[l][h];for(a=[];0<l||0<h;)0==l?(a.push(2),h--):0==h?(a.push(3),l--):(g=b[l-1][h-1],k=b[l-1][h],m=b[l][h-1],q=k<m?k<g?k:g:m<g?m:g,q==g?(g==d?a.push(0):(a.push(1),d=g),l--,h--):q==k?(a.push(3),l--,d=k):(a.push(2),h--,d=m));a.reverse();b=void 0;l=[];for(h=0;h<a.length;h++)switch(a[h]){case 0:b&&(l.push(b),b=void 0);e++;f++;break;case 1:b||(b=r(e,0));b.m++;e++;b.j.push(c[f]);f++;break;case 2:b||(b=r(e,0)); | ||
b.m++;e++;break;case 3:b||(b=r(e,0)),b.j.push(c[f]),f++}b&&l.push(b);return l}function ja(a,b){return a===b};var t=window.ShadyDOM||{};t.R=!(!Element.prototype.attachShadow||!Node.prototype.getRootNode);var u=Object.getOwnPropertyDescriptor(Node.prototype,"firstChild");t.h=!!(u&&u.configurable&&u.get);t.H=t.force||!t.R;function v(a){return a.__shady&&void 0!==a.__shady.firstChild}function w(a){return"ShadyRoot"===a.K}function x(a){a=a.getRootNode();if(w(a))return a}var y=Element.prototype,ka=y.matches||y.matchesSelector||y.mozMatchesSelector||y.msMatchesSelector||y.oMatchesSelector||y.webkitMatchesSelector; | ||
function ia(a,b,c,d){var e=0,f=0,h=0,g=0,k=Math.min(b-e,d-f);if(0==e&&0==f)a:{for(h=0;h<k;h++)if(a[h]!==c[h])break a;h=k}if(b==a.length&&d==c.length){g=a.length;for(var l=c.length,m=0;m<k-h&&ja(a[--g],c[--l]);)m++;g=m}e+=h;f+=h;b-=g;d-=g;if(0==b-e&&0==d-f)return[];if(e==b){for(b=r(e,0);f<d;)b.j.push(c[f++]);return[b]}if(f==d)return[r(e,b-e)];k=e;h=f;d=d-h+1;g=b-k+1;b=Array(d);for(l=0;l<d;l++)b[l]=Array(g),b[l][0]=l;for(l=0;l<g;l++)b[0][l]=l;for(l=1;l<d;l++)for(m=1;m<g;m++)if(a[k+m-1]===c[h+l-1])b[l][m]= | ||
b[l-1][m-1];else{var q=b[l-1][m]+1,z=b[l][m-1]+1;b[l][m]=q<z?q:z}k=b.length-1;h=b[0].length-1;d=b[k][h];for(a=[];0<k||0<h;)0==k?(a.push(2),h--):0==h?(a.push(3),k--):(g=b[k-1][h-1],l=b[k-1][h],m=b[k][h-1],q=l<m?l<g?l:g:m<g?m:g,q==g?(g==d?a.push(0):(a.push(1),d=g),k--,h--):q==l?(a.push(3),k--,d=l):(a.push(2),h--,d=m));a.reverse();b=void 0;k=[];for(h=0;h<a.length;h++)switch(a[h]){case 0:b&&(k.push(b),b=void 0);e++;f++;break;case 1:b||(b=r(e,0));b.m++;e++;b.j.push(c[f]);f++;break;case 2:b||(b=r(e,0)); | ||
b.m++;e++;break;case 3:b||(b=r(e,0)),b.j.push(c[f]),f++}b&&k.push(b);return k}function ja(a,b){return a===b};var t=window.ShadyDOM||{};t.R=!(!Element.prototype.attachShadow||!Node.prototype.getRootNode);var u=Object.getOwnPropertyDescriptor(Node.prototype,"firstChild");t.h=!!(u&&u.configurable&&u.get);t.H=t.force||!t.R;function v(a){return a.__shady&&void 0!==a.__shady.firstChild}function w(a){return"ShadyRoot"===a.K}function x(a){a=a.getRootNode();if(w(a))return a}var y=Element.prototype,ka=y.matches||y.matchesSelector||y.mozMatchesSelector||y.msMatchesSelector||y.oMatchesSelector||y.webkitMatchesSelector; | ||
function A(a,b){if(a&&b)for(var c=Object.getOwnPropertyNames(b),d=0,e;d<c.length&&(e=c[d]);d++){var f=Object.getOwnPropertyDescriptor(b,e);f&&Object.defineProperty(a,e,f)}}function B(a,b){for(var c=[],d=1;d<arguments.length;++d)c[d-1]=arguments[d];for(d=0;d<c.length;d++)A(a,c[d]);return a}function la(a,b){for(var c in b)a[c]=b[c]}var C=document.createTextNode(""),ma=0,D=[];(new MutationObserver(function(){for(;D.length;)try{D.shift()()}catch(a){throw C.textContent=ma++,a;}})).observe(C,{characterData:!0}); | ||
function na(a){D.push(a);C.textContent=ma++}var oa=!!document.contains;function pa(a,b){for(;b;){if(b==a)return!0;b=b.parentNode}return!1};var qa=/[&\u00A0"]/g,sa=/[&\u00A0<>]/g;function ta(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}function ua(a){for(var b={},c=0;c<a.length;c++)b[a[c]]=!0;return b}var va=ua("area base br col command embed hr img input keygen link meta param source track wbr".split(" ")),wa=ua("style script xmp iframe noembed noframes plaintext noscript".split(" ")); | ||
function E(a,b){"template"===a.localName&&(a=a.content);for(var c="",d=b?b(a):a.childNodes,e=0,f=d.length,h;e<f&&(h=d[e]);e++){a:{var g=h;var l=a;var k=b;switch(g.nodeType){case Node.ELEMENT_NODE:for(var m=g.localName,q="<"+m,z=g.attributes,ra=0;l=z[ra];ra++)q+=" "+l.name+'="'+l.value.replace(qa,ta)+'"';q+=">";g=va[m]?q:q+E(g,k)+"</"+m+">";break a;case Node.TEXT_NODE:g=g.data;g=l&&wa[l.localName]?g:g.replace(sa,ta);break a;case Node.COMMENT_NODE:g="\x3c!--"+g.data+"--\x3e";break a;default:throw window.console.error(g), | ||
function E(a,b){"template"===a.localName&&(a=a.content);for(var c="",d=b?b(a):a.childNodes,e=0,f=d.length,h;e<f&&(h=d[e]);e++){a:{var g=h;var k=a;var l=b;switch(g.nodeType){case Node.ELEMENT_NODE:for(var m=g.localName,q="<"+m,z=g.attributes,ra=0;k=z[ra];ra++)q+=" "+k.name+'="'+k.value.replace(qa,ta)+'"';q+=">";g=va[m]?q:q+E(g,l)+"</"+m+">";break a;case Node.TEXT_NODE:g=g.data;g=k&&wa[k.localName]?g:g.replace(sa,ta);break a;case Node.COMMENT_NODE:g="\x3c!--"+g.data+"--\x3e";break a;default:throw window.console.error(g), | ||
Error("not implemented");}}c+=g}return c};var F={},G=document.createTreeWalker(document,NodeFilter.SHOW_ALL,null,!1),H=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT,null,!1);function xa(a){var b=[];G.currentNode=a;for(a=G.firstChild();a;)b.push(a),a=G.nextSibling();return b}F.parentNode=function(a){G.currentNode=a;return G.parentNode()};F.firstChild=function(a){G.currentNode=a;return G.firstChild()};F.lastChild=function(a){G.currentNode=a;return G.lastChild()};F.previousSibling=function(a){G.currentNode=a;return G.previousSibling()}; | ||
@@ -36,6 +36,6 @@ F.nextSibling=function(a){G.currentNode=a;return G.nextSibling()};F.childNodes=xa;F.parentElement=function(a){H.currentNode=a;return H.parentNode()};F.firstElementChild=function(a){H.currentNode=a;return H.firstChild()};F.lastElementChild=function(a){H.currentNode=a;return H.lastChild()};F.previousElementSibling=function(a){H.currentNode=a;return H.previousSibling()};F.nextElementSibling=function(a){H.currentNode=a;return H.nextSibling()}; | ||
function R(a,b){if(b.parentNode!==a)throw Error("The node to be removed is not a child of this node: "+b);var c=x(b);if(v(a)){b.__shady=b.__shady||{};a.__shady=a.__shady||{};b===a.__shady.firstChild&&(a.__shady.firstChild=b.__shady.nextSibling);b===a.__shady.lastChild&&(a.__shady.lastChild=b.__shady.previousSibling);var d=b.__shady.previousSibling,e=b.__shady.nextSibling;d&&(d.__shady=d.__shady||{},d.__shady.nextSibling=e);e&&(e.__shady=e.__shady||{},e.__shady.previousSibling=d);b.__shady.parentNode= | ||
b.__shady.previousSibling=b.__shady.nextSibling=void 0;void 0!==a.__shady.childNodes&&(a.__shady.childNodes=null);if(Sa(a)){S(a.__shady.root);var f=!0}}Va(b);if(c){(d=a&&"slot"===a.localName)&&(f=!0);Wa(c);e=c.a;for(var h in e)for(var g=e[h],l=0;l<g.length;l++){var k=g[l];if(pa(b,k)){g.splice(l,1);var m=c.b.indexOf(k);0<=m&&c.b.splice(m,1);l--;if(m=k.__shady.g)for(k=0;k<m.length;k++){var q=m[k],z=F.parentNode(q);z&&I.removeChild.call(z,q)}m=!0}}(m||d)&&S(c)}f||(f=w(a)?a.host:a,(!a.__shady.root&&"slot"!== | ||
b.__shady.previousSibling=b.__shady.nextSibling=void 0;void 0!==a.__shady.childNodes&&(a.__shady.childNodes=null);if(Sa(a)){S(a.__shady.root);var f=!0}}Va(b);if(c){(d=a&&"slot"===a.localName)&&(f=!0);Wa(c);e=c.a;for(var h in e)for(var g=e[h],k=0;k<g.length;k++){var l=g[k];if(pa(b,l)){g.splice(k,1);var m=c.b.indexOf(l);0<=m&&c.b.splice(m,1);k--;if(m=l.__shady.g)for(l=0;l<m.length;l++){var q=m[l],z=F.parentNode(q);z&&I.removeChild.call(z,q)}m=!0}}(m||d)&&S(c)}f||(f=w(a)?a.host:a,(!a.__shady.root&&"slot"!== | ||
b.localName||f===F.parentNode(b))&&I.removeChild.call(f,b));Ua(a,null,b);return b}function Va(a){if(a.__shady&&void 0!==a.__shady.C)for(var b=a.childNodes,c=0,d=b.length,e;c<d&&(e=b[c]);c++)Va(e);a.__shady&&(a.__shady.C=void 0)}function Ta(a){var b=a;a&&"slot"===a.localName&&(b=(b=a.__shady&&a.__shady.g)&&b.length?b[0]:Ta(a.nextSibling));return b}function Sa(a){return(a=a&&a.__shady&&a.__shady.root)&&Xa(a)} | ||
function Ya(a,b){if("slot"===b)a=a.parentNode,Sa(a)&&S(a.__shady.root);else if("slot"===a.localName&&"name"===b&&(b=x(a))){var c=a.M,d=Za(a);if(d!==c){c=b.a[c];var e=c.indexOf(a);0<=e&&c.splice(e,1);c=b.a[d]||(b.a[d]=[]);c.push(a);1<c.length&&(b.a[d]=$a(c))}S(b)}}function Ua(a,b,c){if(a=a.__shady&&a.__shady.i)b&&a.addedNodes.push(b),c&&a.removedNodes.push(c),ab(a)} | ||
function bb(a){if(a&&a.nodeType){a.__shady=a.__shady||{};var b=a.__shady.C;void 0===b&&(w(a)?b=a:b=(b=a.parentNode)?bb(b):a,I.contains.call(document.documentElement,a)&&(a.__shady.C=b));return b}}function T(a,b,c){var d=[];cb(a.childNodes,b,c,d);return d}function cb(a,b,c,d){for(var e=0,f=a.length,h;e<f&&(h=a[e]);e++){var g;if(g=h.nodeType===Node.ELEMENT_NODE){g=h;var l=b,k=c,m=d,q=l(g);q&&m.push(g);k&&k(q)?g=q:(cb(g.childNodes,l,k,m),g=void 0)}if(g)break}}var U=null; | ||
function bb(a){if(a&&a.nodeType){a.__shady=a.__shady||{};var b=a.__shady.C;void 0===b&&(w(a)?b=a:b=(b=a.parentNode)?bb(b):a,I.contains.call(document.documentElement,a)&&(a.__shady.C=b));return b}}function T(a,b,c){var d=[];cb(a.childNodes,b,c,d);return d}function cb(a,b,c,d){for(var e=0,f=a.length,h;e<f&&(h=a[e]);e++){var g;if(g=h.nodeType===Node.ELEMENT_NODE){g=h;var k=b,l=c,m=d,q=k(g);q&&m.push(g);l&&l(q)?g=q:(cb(g.childNodes,k,l,m),g=void 0)}if(g)break}}var U=null; | ||
function db(a,b,c){U||(U=window.ShadyCSS&&window.ShadyCSS.ScopingShim);U&&"class"===b?U.setElementClass(a,c):(I.setAttribute.call(a,b,c),Ya(a,b))}function eb(a,b){if(a.ownerDocument!==document)return I.importNode.call(document,a,b);var c=I.importNode.call(document,a,!1);if(b){a=a.childNodes;b=0;for(var d;b<a.length;b++)d=eb(a[b],!0),c.appendChild(d)}return c};var V=[],fb;function gb(a){fb||(fb=!0,na(W));V.push(a)}function W(){fb=!1;for(var a=!!V.length;V.length;)V.shift()();return a}W.list=V;var hb={};function X(a,b,c){if(a!==hb)throw new TypeError("Illegal constructor");a=document.createDocumentFragment();a.__proto__=X.prototype;a.K="ShadyRoot";P(b);P(a);a.host=b;a.c=c&&c.mode;b.__shady=b.__shady||{};b.__shady.root=a;b.__shady.S="closed"!==a.c?a:null;a.l=!1;a.b=[];a.a={};a.f=[];c=F.childNodes(b);for(var d=0,e=c.length;d<e;d++)I.removeChild.call(b,c[d]);return a}X.prototype=Object.create(DocumentFragment.prototype);function S(a){a.l||(a.l=!0,gb(function(){return ib(a)}))} | ||
@@ -45,3 +45,3 @@ function ib(a){for(var b;a;){a.l&&(b=a);a:{var c=a;a=c.host.getRootNode();if(w(a))for(var d=c.host.childNodes,e=0;e<d.length;e++)if(c=d[e],"slot"==c.localName)break a;a=void 0}}b&&b._renderRoot()} | ||
b);c=b.parentNode;(c=c.__shady&&c.__shady.root)&&Xa(c)&&c._renderRoot();kb(this,b.__shady.g,b.__shady.assignedNodes);if(c=b.__shady.G){for(d=0;d<c.length;d++)c[d].__shady.A=null;b.__shady.G=null;c.length>b.__shady.assignedNodes.length&&(b.__shady.B=!0)}b.__shady.B&&(b.__shady.B=!1,lb(this,b))}a=this.b;b=[];for(c=0;c<a.length;c++)d=a[c].parentNode,d.__shady&&d.__shady.root||!(0>b.indexOf(d))||b.push(d);for(a=0;a<b.length;a++){c=b[a];d=c===this?this.host:c;e=[];c=c.childNodes;for(var f=0;f<c.length;f++){var h= | ||
c[f];if("slot"==h.localName){h=h.__shady.g;for(var g=0;g<h.length;g++)e.push(h[g])}else e.push(h)}c=void 0;f=F.childNodes(d);h=ia(e,e.length,f,f.length);for(var l=g=0;g<h.length&&(c=h[g]);g++){for(var k=0,m;k<c.j.length&&(m=c.j[k]);k++)F.parentNode(m)===d&&I.removeChild.call(d,m),f.splice(c.index+l,1);l-=c.m}for(l=0;l<h.length&&(c=h[l]);l++)for(g=f[c.index],k=c.index;k<c.index+c.m;k++)m=e[k],I.insertBefore.call(d,m,g),f.splice(k,0,m)}}; | ||
c[f];if("slot"==h.localName){h=h.__shady.g;for(var g=0;g<h.length;g++)e.push(h[g])}else e.push(h)}c=void 0;f=F.childNodes(d);h=ia(e,e.length,f,f.length);for(var k=g=0;g<h.length&&(c=h[g]);g++){for(var l=0,m;l<c.j.length&&(m=c.j[l]);l++)F.parentNode(m)===d&&I.removeChild.call(d,m),f.splice(c.index+k,1);k-=c.m}for(k=0;k<h.length&&(c=h[k]);k++)for(g=f[c.index],l=c.index;l<c.index+c.m;l++)m=e[l],I.insertBefore.call(d,m,g),f.splice(l,0,m)}}; | ||
function jb(a,b,c){b.__shady=b.__shady||{};var d=b.__shady.A;b.__shady.A=null;c||(c=(a=a.a[b.slot||"__catchall"])&&a[0]);c?(c.__shady.assignedNodes.push(b),b.__shady.assignedSlot=c):b.__shady.assignedSlot=void 0;d!==b.__shady.assignedSlot&&b.__shady.assignedSlot&&(b.__shady.assignedSlot.__shady.B=!0)}function kb(a,b,c){for(var d=0,e;d<c.length&&(e=c[d]);d++)if("slot"==e.localName){var f=e.__shady.assignedNodes;f&&f.length&&kb(a,b,f)}else b.push(c[d])} | ||
@@ -58,7 +58,7 @@ function lb(a,b){I.dispatchEvent.call(b,new Event("slotchange"));b.__shady.assignedSlot&&lb(a,b.__shady.assignedSlot)}function Wa(a){if(a.f.length){for(var b=a.f,c,d=0;d<b.length;d++){var e=b[d];e.__shady=e.__shady||{};P(e);P(e.parentNode);var f=Za(e);a.a[f]?(c=c||{},c[f]=!0,a.a[f].push(e)):a.a[f]=[e];a.b.push(e)}if(c)for(var h in c)a.a[h]=$a(a.a[h]);a.f=[]}}function Za(a){var b=a.name||a.getAttribute("name")||"__catchall";return a.M=b} | ||
function Bb(a){var b=a.composedPath();Object.defineProperty(a,"currentTarget",{get:function(){return d},configurable:!0});for(var c=b.length-1;0<=c;c--){var d=b[c];Ab(a,d,"capture");if(a.u)return}Object.defineProperty(a,"eventPhase",{get:function(){return Event.AT_TARGET}});var e;for(c=0;c<b.length;c++){d=b[c];var f=d.__shady&&d.__shady.root;if(0===c||f&&f===e)if(Ab(a,d,"bubble"),d!==window&&(e=d.getRootNode()),a.u)break}} | ||
function Cb(a,b,c,d,e,f){for(var h=0;h<a.length;h++){var g=a[h],l=g.type,k=g.capture,m=g.once,q=g.passive;if(b===g.node&&c===l&&d===k&&e===m&&f===q)return h}return-1} | ||
function Db(a,b,c){if(b){if(c&&"object"===typeof c){var d=!!c.capture;var e=!!c.once;var f=!!c.passive}else d=!!c,f=e=!1;var h=c&&c.w||this,g=b[Y];if(g){if(-1<Cb(g,h,a,d,e,f))return}else b[Y]=[];g=function(d){e&&this.removeEventListener(a,b,c);d.__target||Eb(d);if(h!==this){var f=Object.getOwnPropertyDescriptor(d,"currentTarget");Object.defineProperty(d,"currentTarget",{get:function(){return h},configurable:!0})}if(d.composed||-1<d.composedPath().indexOf(h))if(zb(d)&&d.target===d.relatedTarget)d.eventPhase=== | ||
Event.BUBBLING_PHASE&&d.stopImmediatePropagation();else if(d.eventPhase===Event.CAPTURING_PHASE||d.bubbles||d.target===h||h instanceof Window){var g="object"===typeof b&&b.handleEvent?b.handleEvent(d):b.call(h,d);h!==this&&(f?(Object.defineProperty(d,"currentTarget",f),f=null):delete d.currentTarget);return g}};b[Y].push({node:this,type:a,capture:d,once:e,passive:f,V:g});yb[a]?(this.__handlers=this.__handlers||{},this.__handlers[a]=this.__handlers[a]||{capture:[],bubble:[]},this.__handlers[a][d?"capture": | ||
"bubble"].push(g)):(this instanceof Window?I.T:I.addEventListener).call(this,a,g,c)}} | ||
function Fb(a,b,c){if(b){if(c&&"object"===typeof c){var d=!!c.capture;var e=!!c.once;var f=!!c.passive}else d=!!c,f=e=!1;var h=c&&c.w||this,g=void 0;var l=null;try{l=b[Y]}catch(k){}l&&(e=Cb(l,h,a,d,e,f),-1<e&&(g=l.splice(e,1)[0].V,l.length||(b[Y]=void 0)));(this instanceof Window?I.U:I.removeEventListener).call(this,a,g||b,c);g&&yb[a]&&this.__handlers&&this.__handlers[a]&&(a=this.__handlers[a][d?"capture":"bubble"],g=a.indexOf(g),-1<g&&a.splice(g,1))}} | ||
function Cb(a,b,c,d,e,f){for(var h=0;h<a.length;h++){var g=a[h],k=g.type,l=g.capture,m=g.once,q=g.passive;if(b===g.node&&c===k&&d===l&&e===m&&f===q)return h}return-1} | ||
function Db(a,b,c){var d=typeof b;if("function"===d||"object"===d)if("object"!==d||b.handleEvent&&"function"===typeof b.handleEvent){if(c&&"object"===typeof c){var e=!!c.capture;var f=!!c.once;var h=!!c.passive}else e=!!c,h=f=!1;var g=c&&c.w||this,k=b[Y];if(k){if(-1<Cb(k,g,a,e,f,h))return}else b[Y]=[];k=function(e){f&&this.removeEventListener(a,b,c);e.__target||Eb(e);if(g!==this){var h=Object.getOwnPropertyDescriptor(e,"currentTarget");Object.defineProperty(e,"currentTarget",{get:function(){return g}, | ||
configurable:!0})}if(e.composed||-1<e.composedPath().indexOf(g))if(zb(e)&&e.target===e.relatedTarget)e.eventPhase===Event.BUBBLING_PHASE&&e.stopImmediatePropagation();else if(e.eventPhase===Event.CAPTURING_PHASE||e.bubbles||e.target===g||g instanceof Window){var k="function"===d?b.call(g,e):b.handleEvent&&b.handleEvent(e);g!==this&&(h?(Object.defineProperty(e,"currentTarget",h),h=null):delete e.currentTarget);return k}};b[Y].push({node:this,type:a,capture:e,once:f,passive:h,V:k});yb[a]?(this.__handlers= | ||
this.__handlers||{},this.__handlers[a]=this.__handlers[a]||{capture:[],bubble:[]},this.__handlers[a][e?"capture":"bubble"].push(k)):(this instanceof Window?I.T:I.addEventListener).call(this,a,k,c)}} | ||
function Fb(a,b,c){if(b){if(c&&"object"===typeof c){var d=!!c.capture;var e=!!c.once;var f=!!c.passive}else d=!!c,f=e=!1;var h=c&&c.w||this,g=void 0;var k=null;try{k=b[Y]}catch(l){}k&&(e=Cb(k,h,a,d,e,f),-1<e&&(g=k.splice(e,1)[0].V,k.length||(b[Y]=void 0)));(this instanceof Window?I.U:I.removeEventListener).call(this,a,g||b,c);g&&yb[a]&&this.__handlers&&this.__handlers[a]&&(a=this.__handlers[a][d?"capture":"bubble"],g=a.indexOf(g),-1<g&&a.splice(g,1))}} | ||
function Gb(){for(var a in yb)window.addEventListener(a,function(a){a.__target||(Eb(a),Bb(a))},!0)}function Eb(a){a.__target=a.target;a.v=a.relatedTarget;if(t.h){var b=Object.getPrototypeOf(a);if(!b.hasOwnProperty("__patchProto")){var c=Object.create(b);c.W=b;A(c,wb);b.__patchProto=c}a.__proto__=b.__patchProto}else A(a,wb)}var Hb=xb(window.Event),Ib=xb(window.CustomEvent),Jb=xb(window.MouseEvent);function Kb(a){var b=a.getRootNode();w(b)&&ib(b);return a.__shady&&a.__shady.assignedSlot||null} | ||
@@ -65,0 +65,0 @@ var Lb={addEventListener:Db.bind(window),removeEventListener:Fb.bind(window)},Mb={addEventListener:Db,removeEventListener:Fb,appendChild:function(a){return Q(this,a)},insertBefore:function(a,b){return Q(this,a,b)},removeChild:function(a){return R(this,a)},replaceChild:function(a,b){Q(this,a,b);R(this,b);return a},cloneNode:function(a){if("template"==this.localName)var b=I.cloneNode.call(this,a);else if(b=I.cloneNode.call(this,!1),a){a=this.childNodes;for(var c=0,d;c<a.length;c++)d=a[c].cloneNode(!0), |
@@ -307,6 +307,14 @@ /** | ||
export function addEventListener(type, fnOrObj, optionsOrCapture) { | ||
if (!fnOrObj) { | ||
const handlerType = typeof fnOrObj; | ||
// bail if `fnOrObj` is not a function, not an object | ||
if (handlerType !== 'function' && handlerType !== 'object') { | ||
return; | ||
} | ||
// bail if `fnOrObj` is an object without a `handleEvent` method | ||
if (handlerType === 'object' && (!fnOrObj.handleEvent || typeof fnOrObj.handleEvent !== 'function')) { | ||
return; | ||
} | ||
// The callback `fn` might be used for multiple nodes/events. Since we generate | ||
@@ -375,5 +383,5 @@ // a wrapper function, we need to keep track of it when we remove the listener. | ||
} | ||
let ret = (typeof fnOrObj === 'object' && fnOrObj.handleEvent) ? | ||
fnOrObj.handleEvent(e) : | ||
fnOrObj.call(target, e); | ||
let ret = handlerType === 'function' ? | ||
fnOrObj.call(target, e) : | ||
(fnOrObj.handleEvent && fnOrObj.handleEvent(e)); | ||
if (target !== this) { | ||
@@ -380,0 +388,0 @@ // replace the "correct" `currentTarget` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
514081
3090