@webcomponents/shadydom
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -10,2 +10,7 @@ # Changelog | ||
## [1.11.0] - 2023-03-30 | ||
- Add support for `Element.toggleAttribute()` ([#541](https://github.com/webcomponents/polyfills/pull/541)) | ||
- Update dependencies ([#542](https://github.com/webcomponents/polyfills/pull/542)) | ||
## [1.10.0] - 2022-10-20 | ||
@@ -12,0 +17,0 @@ |
{ | ||
"name": "@webcomponents/shadydom", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -28,3 +28,3 @@ (function(){/* | ||
"innerHTML","className"]),I(HTMLElement.prototype,["children","innerHTML","className"])):(H(Element.prototype,a),H(Element.prototype,{previousElementSibling:{get:function(){K.currentNode=this;return K.previousSibling()}},nextElementSibling:{get:function(){K.currentNode=this;return K.nextSibling()}},innerHTML:{get:function(){return Na(this,sa)},set:function(b){var c="template"===this.localName?this.content:this;Sa(c);var d=this.localName||"div";d=this.namespaceURI&&this.namespaceURI!==Ra.namespaceURI? | ||
Ra.createElementNS(this.namespaceURI,d):Ra.createElement(d);d.innerHTML=b;for(b="template"===this.localName?d.content:d;d=b.__shady_native_firstChild;)c.__shady_native_insertBefore(d,void 0)}},className:{get:function(){return this.getAttribute("class")||""},set:function(b){this.setAttribute("class",b)}}}));I(Element.prototype,"setAttribute getAttribute hasAttribute removeAttribute focus blur".split(" "));I(Element.prototype,Ua);I(HTMLElement.prototype,["focus","blur"]);window.HTMLTemplateElement&& | ||
Ra.createElementNS(this.namespaceURI,d):Ra.createElement(d);d.innerHTML=b;for(b="template"===this.localName?d.content:d;d=b.__shady_native_firstChild;)c.__shady_native_insertBefore(d,void 0)}},className:{get:function(){return this.getAttribute("class")||""},set:function(b){this.setAttribute("class",b)}}}));I(Element.prototype,"setAttribute getAttribute hasAttribute removeAttribute toggleAttribute focus blur".split(" "));I(Element.prototype,Ua);I(HTMLElement.prototype,["focus","blur"]);window.HTMLTemplateElement&& | ||
I(window.HTMLTemplateElement.prototype,["innerHTML"]);G?I(DocumentFragment.prototype,Ta):H(DocumentFragment.prototype,a);I(DocumentFragment.prototype,Ua);G?(I(Document.prototype,Ta),I(Document.prototype,["activeElement"])):H(Document.prototype,a);I(Document.prototype,["importNode","getElementById","elementFromPoint",ia()]);I(Document.prototype,Ua)};var Wa=B({get childNodes(){return this.__shady_childNodes},get firstChild(){return this.__shady_firstChild},get lastChild(){return this.__shady_lastChild},get childElementCount(){return this.__shady_childElementCount},get children(){return this.__shady_children},get firstElementChild(){return this.__shady_firstElementChild},get lastElementChild(){return this.__shady_lastElementChild},get shadowRoot(){return this.__shady_shadowRoot}}),Xa=B({get textContent(){return this.__shady_textContent},set textContent(a){this.__shady_textContent= | ||
@@ -89,3 +89,3 @@ a},get innerHTML(){return this.__shady_innerHTML},set innerHTML(a){this.__shady_innerHTML=a}}),Ya=B({get parentElement(){return this.__shady_parentElement},get parentNode(){return this.__shady_parentNode},get nextSibling(){return this.__shady_nextSibling},get previousSibling(){return this.__shady_previousSibling},get nextElementSibling(){return this.__shady_nextElementSibling},get previousElementSibling(){return this.__shady_previousElementSibling},get className(){return this.__shady_className},set className(a){this.__shady_className= | ||
set slot(a){this.__shady_setAttribute("slot",a)},get className(){return this.getAttribute("class")||""},set className(a){this.__shady_setAttribute("class",a)},setAttribute:function(a,b){this.ownerDocument!==mc?this.__shady_native_setAttribute(a,b):Kb(this,a,b)||(this.__shady_native_setAttribute(a,b),nc(this,a))},removeAttribute:function(a){this.ownerDocument!==mc?this.__shady_native_removeAttribute(a):Kb(this,a,"")?""===this.getAttribute(a)&&this.__shady_native_removeAttribute(a):(this.__shady_native_removeAttribute(a), | ||
nc(this,a))}});v.C||Db.forEach(function(a){rc[a]=Fb(a)}); | ||
nc(this,a))},toggleAttribute:function(a,b){if(this.ownerDocument!==mc)return this.__shady_native_toggleAttribute(a,b);if(!Kb(this,a,""))return b=this.__shady_native_toggleAttribute(a,b),nc(this,a),b;if(""===this.getAttribute(a)&&!b)return this.__shady_native_toggleAttribute(a,b)}});v.C||Db.forEach(function(a){rc[a]=Fb(a)}); | ||
var wc=B({attachShadow:function(a){if(!this)throw Error("Must provide a host.");if(!a)throw Error("Not enough arguments.");if(a.shadyUpgradeFragment&&!v.V){var b=a.shadyUpgradeFragment;b.__proto__=ShadowRoot.prototype;sc(b,this,a);tc(b,b);a=b.__noInsertionPoint?null:b.querySelectorAll("slot");b.__noInsertionPoint=void 0;if(a&&a.length){var c=b;Xb(c);c.j.push.apply(c.j,q(a));Q(b)}b.host.__shady_native_appendChild(b)}else b=new uc(vc,this,a);return this.__CE_shadowRoot=b},get shadowRoot(){var a=u(this); | ||
@@ -116,7 +116,7 @@ return a&&a.ea||null}});wa(rc,wc);var xc=document.implementation.createHTMLDocument("inert"),yc=B({get innerHTML(){return w(this)?Na("template"===this.localName?this.content:this,ta):this.__shady_native_innerHTML},set innerHTML(a){if("template"===this.localName)this.__shady_native_innerHTML=a;else{Tb(this);var b=this.localName||"div";b=this.namespaceURI&&this.namespaceURI!==xc.namespaceURI?xc.createElementNS(this.namespaceURI,b):xc.createElement(b);for(v.i?b.__shady_native_innerHTML=a:b.innerHTML=a;a=b.__shady_firstChild;)this.__shady_insertBefore(a)}}});var zc=B({blur:function(){var a=u(this);(a=(a=a&&a.root)&&a.activeElement)?a.__shady_blur():this.__shady_native_blur()}});v.C||Eb.forEach(function(a){zc[a]=Fb(a)});var Ac=B({assignedNodes:function(a){if("slot"===this.localName){var b=this.__shady_getRootNode();b&&x(b)&&bc(b);return(b=u(this))?(a&&a.flatten?b.u:b.assignedNodes)||[]:[]}},addEventListener:function(a,b,c){if("slot"!==this.localName||"slotchange"===a)vb.call(this,a,b,c);else{"object"!==typeof c&&(c={capture:!!c});var d=this.__shady_parentNode;if(!d)throw Error("ShadyDOM cannot attach event to slot unless it has a `parentNode`");c.o=this;d.__shady_addEventListener(a,b,c)}},removeEventListener:function(a, | ||
$c;Object.defineProperty(window.CustomElementRegistry.prototype,"define",{value:$c,configurable:!0})}function P(a){a=a.__shady_getRootNode();if(x(a))return a};function Z(a){this.node=a}n=Z.prototype;n.addEventListener=function(a,b,c){return this.node.__shady_addEventListener(a,b,c)};n.removeEventListener=function(a,b,c){return this.node.__shady_removeEventListener(a,b,c)};n.appendChild=function(a){return this.node.__shady_appendChild(a)};n.insertBefore=function(a,b){return this.node.__shady_insertBefore(a,b)};n.removeChild=function(a){return this.node.__shady_removeChild(a)};n.replaceChild=function(a,b){return this.node.__shady_replaceChild(a,b)}; | ||
n.cloneNode=function(a){return this.node.__shady_cloneNode(a)};n.getRootNode=function(a){return this.node.__shady_getRootNode(a)};n.contains=function(a){return this.node.__shady_contains(a)};n.dispatchEvent=function(a){return this.node.__shady_dispatchEvent(a)};n.setAttribute=function(a,b){this.node.__shady_setAttribute(a,b)};n.getAttribute=function(a){return this.node.__shady_native_getAttribute(a)};n.removeAttribute=function(a){this.node.__shady_removeAttribute(a)};n.attachShadow=function(a){return this.node.__shady_attachShadow(a)}; | ||
n.focus=function(){this.node.__shady_native_focus()};n.blur=function(){this.node.__shady_blur()};n.importNode=function(a,b){if(this.node.nodeType===Node.DOCUMENT_NODE)return this.node.__shady_importNode(a,b)};n.getElementById=function(a){if(this.node.nodeType===Node.DOCUMENT_NODE)return this.node.__shady_getElementById(a)};n.elementsFromPoint=function(a,b){return this.node.__shady_elementsFromPoint(a,b)};n.elementFromPoint=function(a,b){return this.node.__shady_elementFromPoint(a,b)}; | ||
n.querySelector=function(a){return this.node.__shady_querySelector(a)};n.querySelectorAll=function(a,b){return this.node.__shady_querySelectorAll(a,b)};n.assignedNodes=function(a){if("slot"===this.node.localName)return this.node.__shady_assignedNodes(a)};n.append=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_append.apply(this.node,q(b))}; | ||
n.prepend=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_prepend.apply(this.node,q(b))};n.after=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_after.apply(this.node,q(b))};n.before=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_before.apply(this.node,q(b))};n.remove=function(){return this.node.__shady_remove()}; | ||
n.replaceWith=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_replaceWith.apply(this.node,q(b))}; | ||
n.cloneNode=function(a){return this.node.__shady_cloneNode(a)};n.getRootNode=function(a){return this.node.__shady_getRootNode(a)};n.contains=function(a){return this.node.__shady_contains(a)};n.dispatchEvent=function(a){return this.node.__shady_dispatchEvent(a)};n.setAttribute=function(a,b){this.node.__shady_setAttribute(a,b)};n.getAttribute=function(a){return this.node.__shady_native_getAttribute(a)};n.removeAttribute=function(a){this.node.__shady_removeAttribute(a)}; | ||
n.toggleAttribute=function(a,b){return this.node.__shady_toggleAttribute(a,b)};n.attachShadow=function(a){return this.node.__shady_attachShadow(a)};n.focus=function(){this.node.__shady_native_focus()};n.blur=function(){this.node.__shady_blur()};n.importNode=function(a,b){if(this.node.nodeType===Node.DOCUMENT_NODE)return this.node.__shady_importNode(a,b)};n.getElementById=function(a){if(this.node.nodeType===Node.DOCUMENT_NODE)return this.node.__shady_getElementById(a)}; | ||
n.elementsFromPoint=function(a,b){return this.node.__shady_elementsFromPoint(a,b)};n.elementFromPoint=function(a,b){return this.node.__shady_elementFromPoint(a,b)};n.querySelector=function(a){return this.node.__shady_querySelector(a)};n.querySelectorAll=function(a,b){return this.node.__shady_querySelectorAll(a,b)};n.assignedNodes=function(a){if("slot"===this.node.localName)return this.node.__shady_assignedNodes(a)}; | ||
n.append=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_append.apply(this.node,q(b))};n.prepend=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_prepend.apply(this.node,q(b))};n.after=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_after.apply(this.node,q(b))}; | ||
n.before=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_before.apply(this.node,q(b))};n.remove=function(){return this.node.__shady_remove()};n.replaceWith=function(a){for(var b=[],c=0;c<arguments.length;++c)b[c]=arguments[c];return this.node.__shady_replaceWith.apply(this.node,q(b))}; | ||
ca.Object.defineProperties(Z.prototype,{activeElement:{configurable:!0,enumerable:!0,get:function(){if(x(this.node)||this.node.nodeType===Node.DOCUMENT_NODE)return this.node.__shady_activeElement}},_activeElement:{configurable:!0,enumerable:!0,get:function(){return this.activeElement}},host:{configurable:!0,enumerable:!0,get:function(){if(x(this.node))return this.node.host}},parentNode:{configurable:!0,enumerable:!0,get:function(){return this.node.__shady_parentNode}},firstChild:{configurable:!0, | ||
@@ -123,0 +123,0 @@ enumerable:!0,get:function(){return this.node.__shady_firstChild}},lastChild:{configurable:!0,enumerable:!0,get:function(){return this.node.__shady_lastChild}},nextSibling:{configurable:!0,enumerable:!0,get:function(){return this.node.__shady_nextSibling}},previousSibling:{configurable:!0,enumerable:!0,get:function(){return this.node.__shady_previousSibling}},childNodes:{configurable:!0,enumerable:!0,get:function(){return this.node.__shady_childNodes}},parentElement:{configurable:!0,enumerable:!0, |
@@ -400,2 +400,3 @@ /** | ||
'removeAttribute', | ||
'toggleAttribute', | ||
// on older Safari, these are on Element. | ||
@@ -402,0 +403,0 @@ 'focus', |
@@ -119,6 +119,32 @@ /** | ||
} else if (this.getAttribute(attr) === '') { | ||
// ensure that "class" attribute is fully removed if ShadyCSS does not keep scoping | ||
// When attr='class', scopeClassAttribute() will handle the change as a | ||
// side-effect and return `true`, allowing us to get to this branch, | ||
// which cleans up the 'class' attribute if it's empty and we were | ||
// supposed to have removed it. | ||
this[utils.NATIVE_PREFIX + 'removeAttribute'](attr); | ||
} | ||
}, | ||
/** | ||
* @this {Element} | ||
* @param {string} attr | ||
* @param {boolean | undefined} force | ||
*/ | ||
toggleAttribute(attr, force) { | ||
if (this.ownerDocument !== doc) { | ||
return this[utils.NATIVE_PREFIX + 'toggleAttribute'](attr, force); | ||
} else if (!scopeClassAttribute(this, attr, '')) { | ||
const result = this[utils.NATIVE_PREFIX + 'toggleAttribute'](attr, force); | ||
distributeAttributeChange(this, attr); | ||
return result; | ||
} else if (this.getAttribute(attr) === '' && !force) { | ||
// When attr='class', scopeClassAttribute() will handle the change as a | ||
// side-effect and return `true`, allowing us to get to this branch, | ||
// which cleans up the 'class' attribute if it's empty and we were | ||
// supposed to have removed it. | ||
// We check for `force` being falsey because we only want to clean up on | ||
// removal of the attribute. | ||
return this[utils.NATIVE_PREFIX + 'toggleAttribute'](attr, force); | ||
} | ||
}, | ||
}); | ||
@@ -125,0 +151,0 @@ |
@@ -90,2 +90,6 @@ /** | ||
toggleAttribute(name, force) { | ||
return this.node[utils.SHADY_PREFIX + 'toggleAttribute'](name, force); | ||
} | ||
attachShadow(options) { | ||
@@ -92,0 +96,0 @@ return this.node[utils.SHADY_PREFIX + 'attachShadow'](options); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
592354
6064