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

@spectrum-web-components/shared

Package Overview
Dependencies
Maintainers
7
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/shared - npm Package Compare versions

Comparing version 0.30.1-overlay.31 to 0.30.1-overlay.37

6

package.json
{
"name": "@spectrum-web-components/shared",
"version": "0.30.1-overlay.31+0d83bbe39",
"version": "0.30.1-overlay.37+6ca196138",
"publishConfig": {

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

"@lit-labs/observers": "^2.0.0",
"@spectrum-web-components/base": "^0.30.1-overlay.31+0d83bbe39",
"@spectrum-web-components/base": "^0.30.1-overlay.37+6ca196138",
"focus-visible": "^5.1.0"

@@ -101,3 +101,3 @@ },

],
"gitHead": "0d83bbe39df1adf5e475c05e71ab221b66354a60"
"gitHead": "6ca196138f912339d58406154f27bf31233717c3"
}

@@ -10,3 +10,3 @@ import { ReactiveElement } from '@spectrum-web-components/base';

}
export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, exclude?: string[]): T & Constructor<SlotTextObservingInterface>;
export declare function ObserveSlotText<T extends Constructor<ReactiveElement>>(constructor: T, slotName?: string, excludedSelectors?: string[]): T & Constructor<SlotTextObservingInterface>;
export {};

@@ -19,4 +19,7 @@ "use strict";

const assignedNodesList = Symbol("assignedNodes");
export function ObserveSlotText(constructor, slotName, exclude) {
export function ObserveSlotText(constructor, slotName, excludedSelectors = []) {
var _a;
const notExcluded = (el) => (selector) => {
return el.matches(selector);
};
class SlotTextObservingElement extends constructor {

@@ -46,11 +49,6 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

const assignedNodes = [...this[assignedNodesList]].filter(
(node) => {
(currentNode) => {
const node = currentNode;
if (node.tagName) {
if (exclude == null ? void 0 : exclude.length) {
const shouldExclude = exclude.some(
(selector) => node.matches(selector)
);
return !shouldExclude;
}
return true;
return !excludedSelectors.some(notExcluded(node));
}

@@ -65,11 +63,13 @@ return node.textContent ? node.textContent.trim() : false;

const { childNodes } = this;
const textNodes = [...childNodes].filter((node) => {
const textNodes = [...childNodes].filter((currentNode) => {
const node = currentNode;
if (node.tagName) {
if (exclude == null ? void 0 : exclude.length) {
const shouldExclude = exclude.some(
(selector) => node.matches(selector)
);
return !shouldExclude;
}
return slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot");
const excluded = excludedSelectors.some(
notExcluded(node)
);
return !excluded ? (
// This pass happens at element upgrade and before slot rendering.
// Confirm it would exisit in a targeted slot if there was one supplied.
slotName ? node.getAttribute("slot") === slotName : !node.hasAttribute("slot")
) : false;
}

@@ -76,0 +76,0 @@ return node.textContent ? node.textContent.trim() : false;

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

"use strict";var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var c=(i,r,t,s)=>{for(var e=s>1?void 0:s?h(r,t):r,l=i.length-1,u;l>=0;l--)(u=i[l])&&(e=(s?u(r,t,e):u(e))||e);return s&&e&&d(r,t,e),e};import{property as g,queryAssignedNodes as T}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as b}from"@lit-labs/observers/mutation-controller.js";const m=Symbol("assignedNodes");export function ObserveSlotText(i,r,t){var e;class s extends i{constructor(...a){super(a);this.slotHasContent=!1;new b(this,{config:{characterData:!0,subtree:!0},callback:o=>{for(const p of o)if(p.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[m])return;const a=[...this[m]].filter(o=>o.tagName?t!=null&&t.length?!t.some(n=>o.matches(n)):!0:o.textContent?o.textContent.trim():!1);this.slotHasContent=a.length>0}update(a){if(!this.hasUpdated){const{childNodes:o}=this,p=[...o].filter(n=>n.tagName?t!=null&&t.length?!t.some(f=>n.matches(f)):r?n.getAttribute("slot")===r:!n.hasAttribute("slot"):n.textContent?n.textContent.trim():!1);this.slotHasContent=p.length>0}super.update(a)}firstUpdated(a){super.firstUpdated(a),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return e=m,c([g({type:Boolean,attribute:!1})],s.prototype,"slotHasContent",2),c([T(r,!0)],s.prototype,e,2),s}
"use strict";var g=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var u=(c,e,s,o)=>{for(var t=o>1?void 0:o?h(e,s):e,d=c.length-1,a;d>=0;d--)(a=c[d])&&(t=(o?a(e,s,t):a(t))||t);return o&&t&&g(e,s,t),t};import{property as x,queryAssignedNodes as T}from"@spectrum-web-components/base/src/decorators.js";import{MutationController as b}from"@lit-labs/observers/mutation-controller.js";const p=Symbol("assignedNodes");export function ObserveSlotText(c,e,s=[]){var d;const o=a=>f=>a.matches(f);class t extends c{constructor(...n){super(n);this.slotHasContent=!1;new b(this,{config:{characterData:!0,subtree:!0},callback:l=>{for(const r of l)if(r.type==="characterData"){this.manageTextObservedSlot();return}}})}manageTextObservedSlot(){if(!this[p])return;const n=[...this[p]].filter(l=>{const r=l;return r.tagName?!s.some(o(r)):r.textContent?r.textContent.trim():!1});this.slotHasContent=n.length>0}update(n){if(!this.hasUpdated){const{childNodes:l}=this,r=[...l].filter(m=>{const i=m;return i.tagName?s.some(o(i))?!1:e?i.getAttribute("slot")===e:!i.hasAttribute("slot"):i.textContent?i.textContent.trim():!1});this.slotHasContent=r.length>0}super.update(n)}firstUpdated(n){super.firstUpdated(n),this.updateComplete.then(()=>{this.manageTextObservedSlot()})}}return d=p,u([x({type:Boolean,attribute:!1})],t.prototype,"slotHasContent",2),u([T(e,!0)],t.prototype,d,2),t}
//# sourceMappingURL=observe-slot-text.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