Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spectrum-web-components/reactive-controllers

Package Overview
Dependencies
Maintainers
7
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/reactive-controllers - npm Package Compare versions

Comparing version 0.39.3 to 0.39.4

4

package.json
{
"name": "@spectrum-web-components/reactive-controllers",
"version": "0.39.3",
"version": "0.39.4",
"publishConfig": {

@@ -82,3 +82,3 @@ "access": "public"

],
"gitHead": "d7840b3a9b99db4de62c44e3fb91b69dec7319af"
"gitHead": "f745c90e8e9ea85ff10be025e058b14cc925ec9f"
}

@@ -12,2 +12,4 @@ import type { ReactiveController, ReactiveElement } from 'lit';

private _selector;
get selectorAsId(): string;
get selectorIsId(): boolean;
constructor(host: ReactiveElement, { selector }?: {

@@ -21,2 +23,3 @@ selector: string;

private releaseElement;
private elementIsSelected;
}

@@ -15,6 +15,3 @@ "use strict";

const matchingElementAdded = !!this.selector && [...mutation.addedNodes].some(
(el) => {
var _a;
return (_a = el == null ? void 0 : el.matches) == null ? void 0 : _a.call(el, this.selector);
}
this.elementIsSelected
);

@@ -25,3 +22,3 @@ needsResolution = needsResolution || currentElementRemoved || matchingElementAdded;

const attributeChangedOnCurrentElement = mutation.target === this.element;
const attributeChangedOnMatchingElement = !!this.selector && mutation.target.matches(this.selector);
const attributeChangedOnMatchingElement = !!this.selector && this.elementIsSelected(mutation.target);
needsResolution = needsResolution || attributeChangedOnCurrentElement || attributeChangedOnMatchingElement;

@@ -34,2 +31,6 @@ }

};
this.elementIsSelected = (el) => {
var _a;
return this.selectorIsId ? (el == null ? void 0 : el.id) === this.selectorAsId : (_a = el == null ? void 0 : el.matches) == null ? void 0 : _a.call(el, this.selector);
};
this.host = host;

@@ -60,2 +61,8 @@ this.selector = selector;

}
get selectorAsId() {
return this.selector.slice(1);
}
get selectorIsId() {
return !!this.selector && this.selector.startsWith("#");
}
hostConnected() {

@@ -79,3 +86,3 @@ this.resolveElement();

const parent = this.host.getRootNode();
this.element = parent.querySelector(this.selector);
this.element = this.selectorIsId ? parent.getElementById(this.selectorAsId) : parent.querySelector(this.selector);
}

@@ -82,0 +89,0 @@ releaseElement() {

@@ -1,2 +0,2 @@

"use strict";export const elementResolverUpdatedSymbol=Symbol("element resolver updated");export class ElementResolutionController{constructor(e,{selector:t}={selector:""}){this._element=null;this._selector="";this.mutationCallback=e=>{let t=!1;e.forEach(s=>{if(!t){if(s.type==="childList"){const l=this.element&&[...s.removedNodes].includes(this.element),n=!!this.selector&&[...s.addedNodes].some(r=>{var o;return(o=r==null?void 0:r.matches)==null?void 0:o.call(r,this.selector)});t=t||l||n}if(s.type==="attributes"){const l=s.target===this.element,n=!!this.selector&&s.target.matches(this.selector);t=t||l||n}}}),t&&this.resolveElement()};this.host=e,this.selector=t,this.observer=new MutationObserver(this.mutationCallback),this.host.addController(this)}get element(){return this._element}set element(e){if(e===this.element)return;const t=this.element;this._element=e,this.host.requestUpdate(elementResolverUpdatedSymbol,t)}get selector(){return this._selector}set selector(e){e!==this.selector&&(this.releaseElement(),this._selector=e,this.resolveElement())}hostConnected(){this.resolveElement(),this.observer.observe(this.host.getRootNode(),{subtree:!0,childList:!0,attributes:!0})}hostDisconnected(){this.releaseElement(),this.observer.disconnect()}resolveElement(){if(!this.selector){this.releaseElement();return}const e=this.host.getRootNode();this.element=e.querySelector(this.selector)}releaseElement(){this.element=null}}
"use strict";export const elementResolverUpdatedSymbol=Symbol("element resolver updated");export class ElementResolutionController{constructor(e,{selector:t}={selector:""}){this._element=null;this._selector="";this.mutationCallback=e=>{let t=!1;e.forEach(s=>{if(!t){if(s.type==="childList"){const r=this.element&&[...s.removedNodes].includes(this.element),l=!!this.selector&&[...s.addedNodes].some(this.elementIsSelected);t=t||r||l}if(s.type==="attributes"){const r=s.target===this.element,l=!!this.selector&&this.elementIsSelected(s.target);t=t||r||l}}}),t&&this.resolveElement()};this.elementIsSelected=e=>{var t;return this.selectorIsId?(e==null?void 0:e.id)===this.selectorAsId:(t=e==null?void 0:e.matches)==null?void 0:t.call(e,this.selector)};this.host=e,this.selector=t,this.observer=new MutationObserver(this.mutationCallback),this.host.addController(this)}get element(){return this._element}set element(e){if(e===this.element)return;const t=this.element;this._element=e,this.host.requestUpdate(elementResolverUpdatedSymbol,t)}get selector(){return this._selector}set selector(e){e!==this.selector&&(this.releaseElement(),this._selector=e,this.resolveElement())}get selectorAsId(){return this.selector.slice(1)}get selectorIsId(){return!!this.selector&&this.selector.startsWith("#")}hostConnected(){this.resolveElement(),this.observer.observe(this.host.getRootNode(),{subtree:!0,childList:!0,attributes:!0})}hostDisconnected(){this.releaseElement(),this.observer.disconnect()}resolveElement(){if(!this.selector){this.releaseElement();return}const e=this.host.getRootNode();this.element=this.selectorIsId?e.getElementById(this.selectorAsId):e.querySelector(this.selector)}releaseElement(){this.element=null}}
//# sourceMappingURL=ElementResolution.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc