chore: portal needs scoped registry polyfill

This commit is contained in:
Thomas Allmer 2022-04-05 16:52:58 +02:00
parent 0f8488e13c
commit e913489344
7 changed files with 51 additions and 0 deletions

View file

@ -8,3 +8,6 @@ _site-dev
_site _site
docs/_merged_* docs/_merged_*
patches/ patches/
/docs/_assets/scoped-custom-element-registry.min.js
/docs/_assets/scoped-custom-element-registry.min.js.map

View file

@ -4,3 +4,6 @@ bundlesize/
_site _site
_site-dev _site-dev
.history .history
/docs/_assets/scoped-custom-element-registry.min.js
/docs/_assets/scoped-custom-element-registry.min.js.map

View file

@ -0,0 +1,37 @@
(function(){
/*
Copyright (c) 2020 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at
http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at
http://polymer.github.io/PATENTS.txt
*/
'use strict';function g(b){var c=0;return function(){return c<b.length?{done:!1,value:b[c++]}:{done:!0}}}function h(b){var c="undefined"!=typeof Symbol&&Symbol.iterator&&b[Symbol.iterator];return c?c.call(b):{next:g(b)}}function l(b){if(!(b instanceof Array)){b=h(b);for(var c,a=[];!(c=b.next()).done;)a.push(c.value);b=a}return b}var m="function"==typeof Object.create?Object.create:function(b){function c(){}c.prototype=b;return new c};
function n(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var c=0;c<b.length;++c){var a=b[c];if(a&&a.Math==Math)return a}throw Error("Cannot find global object");}
var p=n(this),q=function(){function b(){function a(){}new a;Reflect.construct(a,[],function(){});return new a instanceof a}if("undefined"!=typeof Reflect&&Reflect.construct){if(b())return Reflect.construct;var c=Reflect.construct;return function(a,d,e){a=c(a,d);e&&Reflect.setPrototypeOf(a,e.prototype);return a}}return function(a,d,e){void 0===e&&(e=a);e=m(e.prototype||Object.prototype);return Function.prototype.apply.call(a,e,d)||e}}(),r;
if("function"==typeof Object.setPrototypeOf)r=Object.setPrototypeOf;else{var t;a:{var u={a:!0},v={};try{v.__proto__=u;t=v.a;break a}catch(b){}t=!1}r=t?function(b,c){b.__proto__=c;if(b.__proto__!==c)throw new TypeError(b+" is not extensible");return b}:null}var w=r;
if(!ShadowRoot.prototype.createElement){var x=window.HTMLElement,y=window.customElements.define,z=window.customElements.get,A=window.customElements,B=new WeakMap,C=new WeakMap,D=new WeakMap,E=new WeakMap;window.CustomElementRegistry=function(){this.l=new Map;this.o=new Map;this.i=new Map;this.h=new Map};window.CustomElementRegistry.prototype.define=function(b,c){b=b.toLowerCase();if(void 0!==this.j(b))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \""+b+'" has already been used with this registry');
if(void 0!==this.o.get(c))throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");var a=c.prototype.attributeChangedCallback,d=new Set(c.observedAttributes||[]);F(c,d,a);a={g:c,connectedCallback:c.prototype.connectedCallback,disconnectedCallback:c.prototype.disconnectedCallback,adoptedCallback:c.prototype.adoptedCallback,attributeChangedCallback:a,formAssociated:c.formAssociated,formAssociatedCallback:c.prototype.formAssociatedCallback,
formDisabledCallback:c.prototype.formDisabledCallback,formResetCallback:c.prototype.formResetCallback,formStateRestoreCallback:c.prototype.formStateRestoreCallback,observedAttributes:d};this.l.set(b,a);this.o.set(c,a);d=z.call(A,b);d||(d=G(b),y.call(A,b,d));this===window.customElements&&(D.set(c,a),a.s=d);if(d=this.h.get(b)){this.h.delete(b);d=h(d);for(var e=d.next();!e.done;e=d.next())e=e.value,C.delete(e),H(e,a,!0)}a=this.i.get(b);void 0!==a&&(a.resolve(c),this.i.delete(b));return c};window.CustomElementRegistry.prototype.upgrade=
function(){I.push(this);A.upgrade.apply(A,arguments);I.pop()};window.CustomElementRegistry.prototype.get=function(b){var c;return null==(c=this.l.get(b))?void 0:c.g};window.CustomElementRegistry.prototype.j=function(b){return this.l.get(b)};window.CustomElementRegistry.prototype.whenDefined=function(b){var c=this.j(b);if(void 0!==c)return Promise.resolve(c.g);var a=this.i.get(b);void 0===a&&(a={},a.promise=new Promise(function(d){return a.resolve=d}),this.i.set(b,a));return a.promise};window.CustomElementRegistry.prototype.m=
function(b,c,a){var d=this.h.get(c);d||this.h.set(c,d=new Set);a?d.add(b):d.delete(b)};var J;window.HTMLElement=function(){var b=J;if(b)return J=void 0,b;var c=D.get(this.constructor);if(!c)throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)");b=Reflect.construct(x,[],c.s);Object.setPrototypeOf(b,this.constructor.prototype);B.set(b,c);return b};window.HTMLElement.prototype=x.prototype;var G=function(b){function c(){var a=
Reflect.construct(x,[],this.constructor);Object.setPrototypeOf(a,HTMLElement.prototype);a:{var d=a.getRootNode();if(!(d===document||d instanceof ShadowRoot)){d=I[I.length-1];if(d instanceof CustomElementRegistry){var e=d;break a}d=d.getRootNode();d===document||d instanceof ShadowRoot||(d=(null==(e=E.get(d))?void 0:e.getRootNode())||document)}e=d.customElements}e=e||window.customElements;(d=e.j(b))?H(a,d):C.set(a,e);return a}p.Object.defineProperty(c,"formAssociated",{configurable:!0,enumerable:!0,
get:function(){return!0}});c.prototype.connectedCallback=function(){var a=B.get(this);a?a.connectedCallback&&a.connectedCallback.apply(this,arguments):C.get(this).m(this,b,!0)};c.prototype.disconnectedCallback=function(){var a=B.get(this);a?a.disconnectedCallback&&a.disconnectedCallback.apply(this,arguments):C.get(this).m(this,b,!1)};c.prototype.adoptedCallback=function(){var a,d;null==(a=B.get(this))||null==(d=a.adoptedCallback)||d.apply(this,arguments)};c.prototype.formAssociatedCallback=function(){var a=
B.get(this);if(a&&a.formAssociated){var d;null==a||null==(d=a.formAssociatedCallback)||d.apply(this,arguments)}};c.prototype.formDisabledCallback=function(){var a=B.get(this);if(null==a?0:a.formAssociated){var d;null==a||null==(d=a.formDisabledCallback)||d.apply(this,arguments)}};c.prototype.formResetCallback=function(){var a=B.get(this);if(null==a?0:a.formAssociated){var d;null==a||null==(d=a.formResetCallback)||d.apply(this,arguments)}};c.prototype.formStateRestoreCallback=function(){var a=B.get(this);
if(null==a?0:a.formAssociated){var d;null==a||null==(d=a.formStateRestoreCallback)||d.apply(this,arguments)}};return c},F=function(b,c,a){if(0!==c.size&&void 0!==a){var d=b.prototype.setAttribute;d&&(b.prototype.setAttribute=function(f,k){f=f.toLowerCase();if(c.has(f)){var T=this.getAttribute(f);d.call(this,f,k);a.call(this,f,T,k)}else d.call(this,f,k)});var e=b.prototype.removeAttribute;e&&(b.prototype.removeAttribute=function(f){f=f.toLowerCase();if(c.has(f)){var k=this.getAttribute(f);e.call(this,
f);a.call(this,f,k,null)}else e.call(this,f)})}},K=function(b){var c=Object.getPrototypeOf(b);if(c!==window.HTMLElement)return c===x?Object.setPrototypeOf(b,window.HTMLElement):K(c)},H=function(b,c,a){a=void 0===a?!1:a;Object.setPrototypeOf(b,c.g.prototype);B.set(b,c);J=b;try{new c.g}catch(d){K(c.g),new c.g}c.observedAttributes.forEach(function(d){b.hasAttribute(d)&&c.attributeChangedCallback.call(b,d,null,b.getAttribute(d))});a&&c.connectedCallback&&b.isConnected&&c.connectedCallback.call(b)},L=
Element.prototype.attachShadow;Element.prototype.attachShadow=function(b){var c=L.apply(this,arguments);b.customElements&&(c.customElements=b.customElements);return c};var I=[document],M=function(b,c,a){var d=(a?Object.getPrototypeOf(a):b.prototype)[c];b.prototype[c]=function(){I.push(this);var e=d.apply(a||this,arguments);void 0!==e&&E.set(e,this);I.pop();return e}};M(ShadowRoot,"createElement",document);M(ShadowRoot,"importNode",document);M(Element,"insertAdjacentHTML");var N=function(b){var c=
Object.getOwnPropertyDescriptor(b.prototype,"innerHTML");Object.defineProperty(b.prototype,"innerHTML",Object.assign({},c,{set:function(a){I.push(this);c.set.call(this,a);I.pop()}}))};N(Element);N(ShadowRoot);Object.defineProperty(window,"customElements",{value:new CustomElementRegistry,configurable:!0,writable:!0});if(window.ElementInternals&&window.ElementInternals.prototype.setFormValue){var O=new WeakMap,P=HTMLElement.prototype.attachInternals,methods=["setFormValue","setValidity","checkValidity",
"reportValidity"];HTMLElement.prototype.attachInternals=function(b){for(var c=[],a=0;a<arguments.length;++a)c[a]=arguments[a];c=P.call.apply(P,[this].concat(l(c)));O.set(c,this);return c};methods.forEach(function(b){var c=window.ElementInternals.prototype,a=c[b];c[b]=function(d){for(var e=[],f=0;f<arguments.length;++f)e[f]=arguments[f];f=O.get(this);if(!0===B.get(f).formAssociated)null==a||a.call.apply(a,[this].concat(l(e)));else throw new DOMException("Failed to execute "+a+" on 'ElementInternals': The target element is not a form-associated custom element.");
}});var RadioNodeList=function(b){var c=q(Array,[].concat(l(b)),this.constructor);c.h=b;return c},Q=RadioNodeList,R=Array;Q.prototype=m(R.prototype);Q.prototype.constructor=Q;if(w)w(Q,R);else for(var S in R)if("prototype"!=S)if(Object.defineProperties){var U=Object.getOwnPropertyDescriptor(R,S);U&&Object.defineProperty(Q,S,U)}else Q[S]=R[S];Q.u=R.prototype;p.Object.defineProperty(RadioNodeList.prototype,"value",{configurable:!0,enumerable:!0,get:function(){var b;return(null==(b=this.h.find(function(c){return!0===
c.checked}))?void 0:b.value)||""}});var HTMLFormControlsCollection=function(b){var c=this,a=new Map;b.forEach(function(d,e){var f=d.getAttribute("name"),k=a.get(f)||[];c[+e]=d;k.push(d);a.set(f,k)});this.length=b.length;a.forEach(function(d,e){d&&(c[e]=1===d.length?d[0]:new RadioNodeList(d))})};HTMLFormControlsCollection.prototype.namedItem=function(b){return this[b]};var V=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"elements");Object.defineProperty(HTMLFormElement.prototype,"elements",
{get:function(){var b=V.get.call(this,[]),c=[];b=h(b);for(var a=b.next();!a.done;a=b.next()){a=a.value;var d=B.get(a);d&&!0!==d.formAssociated||c.push(a)}return new HTMLFormControlsCollection(c)}})}};
}).call(typeof globalThis === 'object' ? globalThis : window);
//# sourceMappingURL=scoped-custom-element-registry.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
<script src="{{ '/_assets/scoped-custom-element-registry.min.js' | asset | url }}"></script>

View file

@ -61,6 +61,7 @@
"@web/test-runner-browserstack": "^0.5.0", "@web/test-runner-browserstack": "^0.5.0",
"@web/test-runner-commands": "^0.6.1", "@web/test-runner-commands": "^0.6.1",
"@web/test-runner-playwright": "^0.8.8", "@web/test-runner-playwright": "^0.8.8",
"@webcomponents/scoped-custom-element-registry": "^0.0.5",
"@yarnpkg/lockfile": "^1.1.0", "@yarnpkg/lockfile": "^1.1.0",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"bundlesize": "^1.0.0-beta.2", "bundlesize": "^1.0.0-beta.2",

View file

@ -2967,6 +2967,11 @@
portfinder "^1.0.28" portfinder "^1.0.28"
source-map "^0.7.3" source-map "^0.7.3"
"@webcomponents/scoped-custom-element-registry@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@webcomponents/scoped-custom-element-registry/-/scoped-custom-element-registry-0.0.5.tgz#96377f6a5587c76479b90d13deb7674b51b82603"
integrity sha512-vtlIyf+b657A1MWY69uTTJaGYwqUS3Lnm0+n2vLyuVf5MYOwSOB3Mx42AyBxz/6t9gw+IDelm1HQFOiA1xZCEQ==
"@webcomponents/shadycss@^1.10.2": "@webcomponents/shadycss@^1.10.2":
version "1.10.2" version "1.10.2"
resolved "https://registry.yarnpkg.com/@webcomponents/shadycss/-/shadycss-1.10.2.tgz#40e03cab6dc5e12f199949ba2b79e02f183d1e7b" resolved "https://registry.yarnpkg.com/@webcomponents/shadycss/-/shadycss-1.10.2.tgz#40e03cab6dc5e12f199949ba2b79e02f183d1e7b"