@vaadin/component-base
Advanced tools
+4
-4
| { | ||
| "name": "@vaadin/component-base", | ||
| "version": "25.3.0-alpha11", | ||
| "version": "25.3.0-alpha12", | ||
| "publishConfig": { | ||
@@ -42,4 +42,4 @@ "access": "public" | ||
| "@polymer/polymer": "^3.0.0", | ||
| "@vaadin/chai-plugins": "25.3.0-alpha11", | ||
| "@vaadin/test-runner-commands": "25.3.0-alpha11", | ||
| "@vaadin/chai-plugins": "25.3.0-alpha12", | ||
| "@vaadin/test-runner-commands": "25.3.0-alpha12", | ||
| "@vaadin/testing-helpers": "^2.0.0", | ||
@@ -49,3 +49,3 @@ "sinon": "^22.0.0" | ||
| "customElements": "custom-elements.json", | ||
| "gitHead": "7e0c61a37e68d8971def9cdf28ad0548a0f530a9" | ||
| "gitHead": "0f0337783efe38332f5dc6a8968f207d2982de4b" | ||
| } |
+1
-1
@@ -16,3 +16,3 @@ /** | ||
| export function defineCustomElement(CustomElement, version = '25.3.0-alpha11') { | ||
| export function defineCustomElement(CustomElement, version = '25.3.0-alpha12') { | ||
| Object.defineProperty(CustomElement, 'version', { | ||
@@ -19,0 +19,0 @@ get() { |
@@ -65,1 +65,8 @@ /** | ||
| export function isEmptyTextNode(node: Node): boolean; | ||
| /** | ||
| * Returns true if the given node has content of its own: an element with | ||
| * children, a defined custom element — which may render content in its | ||
| * shadow root — or a node with non-empty text. | ||
| */ | ||
| export function hasNodeContent(node: Node | null | undefined): boolean; |
+19
-0
@@ -171,1 +171,20 @@ /** | ||
| } | ||
| /** | ||
| * Returns true if the given node has content of its own: an element with | ||
| * children, a defined custom element — which may render content in its | ||
| * shadow root — or a node with non-empty text. | ||
| * | ||
| * @param {Node | null | undefined} node | ||
| * @return {boolean} | ||
| */ | ||
| export function hasNodeContent(node) { | ||
| if (!node) { | ||
| return false; | ||
| } | ||
| return Boolean( | ||
| (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) || | ||
| node.textContent?.trim(), | ||
| ); | ||
| } |
@@ -6,2 +6,3 @@ /** | ||
| */ | ||
| import { hasNodeContent } from './dom-utils.js'; | ||
| import { SlotController } from './slot-controller.js'; | ||
@@ -135,20 +136,2 @@ | ||
| /** | ||
| * Returns true if a node is an HTML element with children, | ||
| * or is a defined custom element, or has non-empty text. | ||
| * | ||
| * @param {Node} node | ||
| * @return {boolean} | ||
| */ | ||
| #hasContent(node) { | ||
| if (!node) { | ||
| return false; | ||
| } | ||
| return ( | ||
| (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) || | ||
| (node.textContent && node.textContent.trim() !== '') | ||
| ); | ||
| } | ||
| /** | ||
| * Fire an event to notify the controller host about node changes. | ||
@@ -162,3 +145,3 @@ * | ||
| new CustomEvent('slot-content-changed', { | ||
| detail: { hasContent: this.#hasContent(node), node }, | ||
| detail: { hasContent: hasNodeContent(node), node }, | ||
| }), | ||
@@ -165,0 +148,0 @@ ); |
262169
0.15%7356
0.11%