@vaadin/component-base 25.3.0-alpha11 → 25.3.0-alpha12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "25.3.0-alpha11",
3
+ "version": "25.3.0-alpha12",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/chai-plugins": "25.3.0-alpha11",
43
- "@vaadin/test-runner-commands": "25.3.0-alpha11",
42
+ "@vaadin/chai-plugins": "25.3.0-alpha12",
43
+ "@vaadin/test-runner-commands": "25.3.0-alpha12",
44
44
  "@vaadin/testing-helpers": "^2.0.0",
45
45
  "sinon": "^22.0.0"
46
46
  },
47
47
  "customElements": "custom-elements.json",
48
- "gitHead": "7e0c61a37e68d8971def9cdf28ad0548a0f530a9"
48
+ "gitHead": "0f0337783efe38332f5dc6a8968f207d2982de4b"
49
49
  }
package/src/define.js CHANGED
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
13
13
 
14
14
  const experimentalMap = {};
15
15
 
16
- export function defineCustomElement(CustomElement, version = '25.3.0-alpha11') {
16
+ export function defineCustomElement(CustomElement, version = '25.3.0-alpha12') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
@@ -62,3 +62,10 @@ export function removeValuesFromAttribute(element: HTMLElement, attr: string, va
62
62
  * Returns true if the given node is an empty text node, false otherwise.
63
63
  */
64
64
  export function isEmptyTextNode(node: Node): boolean;
65
+
66
+ /**
67
+ * Returns true if the given node has content of its own: an element with
68
+ * children, a defined custom element — which may render content in its
69
+ * shadow root — or a node with non-empty text.
70
+ */
71
+ export function hasNodeContent(node: Node | null | undefined): boolean;
package/src/dom-utils.js CHANGED
@@ -168,3 +168,22 @@ export function removeValuesFromAttribute(element, attr, valuesToRemove) {
168
168
  export function isEmptyTextNode(node) {
169
169
  return node.nodeType === Node.TEXT_NODE && node.textContent.trim() === '';
170
170
  }
171
+
172
+ /**
173
+ * Returns true if the given node has content of its own: an element with
174
+ * children, a defined custom element — which may render content in its
175
+ * shadow root — or a node with non-empty text.
176
+ *
177
+ * @param {Node | null | undefined} node
178
+ * @return {boolean}
179
+ */
180
+ export function hasNodeContent(node) {
181
+ if (!node) {
182
+ return false;
183
+ }
184
+
185
+ return Boolean(
186
+ (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) ||
187
+ node.textContent?.trim(),
188
+ );
189
+ }
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2022 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { hasNodeContent } from './dom-utils.js';
6
7
  import { SlotController } from './slot-controller.js';
7
8
 
8
9
  /**
@@ -130,24 +131,6 @@ export class SlotChildObserveController extends SlotController {
130
131
  });
131
132
  }
132
133
 
133
- /**
134
- * Returns true if a node is an HTML element with children,
135
- * or is a defined custom element, or has non-empty text.
136
- *
137
- * @param {Node} node
138
- * @return {boolean}
139
- */
140
- #hasContent(node) {
141
- if (!node) {
142
- return false;
143
- }
144
-
145
- return (
146
- (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) ||
147
- (node.textContent && node.textContent.trim() !== '')
148
- );
149
- }
150
-
151
134
  /**
152
135
  * Fire an event to notify the controller host about node changes.
153
136
  *
@@ -157,7 +140,7 @@ export class SlotChildObserveController extends SlotController {
157
140
  _notifyChange(node) {
158
141
  this.dispatchEvent(
159
142
  new CustomEvent('slot-content-changed', {
160
- detail: { hasContent: this.#hasContent(node), node },
143
+ detail: { hasContent: hasNodeContent(node), node },
161
144
  }),
162
145
  );
163
146
  }