@vaadin/component-base 23.3.0-alpha1 → 23.3.0-alpha2

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": "23.3.0-alpha1",
3
+ "version": "23.3.0-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -42,5 +42,5 @@
42
42
  "@vaadin/testing-helpers": "^0.3.2",
43
43
  "sinon": "^13.0.2"
44
44
  },
45
- "gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
45
+ "gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
46
46
  }
@@ -23,3 +23,8 @@ export function addValueToAttribute(element: HTMLElement, attr: string, value: s
23
23
  * If the value is the last one, the whole attribute is removed.
24
24
  */
25
25
  export function removeValueFromAttribute(element: HTMLElement, attr: string, value: string): void;
26
+
27
+ /**
28
+ * Returns true if the given node is an empty text node, false otherwise.
29
+ */
30
+ export function isEmptyTextNode(node: Node): boolean;
package/src/dom-utils.js CHANGED
@@ -90,3 +90,13 @@ export function removeValueFromAttribute(element, attr, value) {
90
90
  }
91
91
  element.setAttribute(attr, serializeAttributeValue(values));
92
92
  }
93
+
94
+ /**
95
+ * Returns true if the given node is an empty text node, false otherwise.
96
+ *
97
+ * @param {Node} node
98
+ * @return {boolean}
99
+ */
100
+ export function isEmptyTextNode(node) {
101
+ return node.nodeType === Node.TEXT_NODE && node.textContent.trim() === '';
102
+ }
@@ -39,7 +39,7 @@ const registered = new Set();
39
39
  export const ElementMixin = (superClass) =>
40
40
  class VaadinElementMixin extends DirMixin(superClass) {
41
41
  static get version() {
42
- return '23.3.0-alpha1';
42
+ return '23.3.0-alpha2';
43
43
  }
44
44
 
45
45
  /** @protected */
@@ -24,7 +24,7 @@ type TooltipPosition =
24
24
  */
25
25
  export class TooltipController extends SlotController {
26
26
  /**
27
- * Object with properties passed to `textGenerator`
27
+ * Object with properties passed to `generator`
28
28
  * function to be used for generating tooltip text.
29
29
  */
30
30
  context: Record<string, unknown>;
@@ -52,7 +52,7 @@ export class TooltipController extends SlotController {
52
52
  target: HTMLElement;
53
53
 
54
54
  /**
55
- * Set a context object to be used by text generator.
55
+ * Set a context object to be used by generator.
56
56
  */
57
57
  setContext(context: Record<string, unknown>): void;
58
58
 
@@ -39,7 +39,7 @@ export class TooltipController extends SlotController {
39
39
  }
40
40
 
41
41
  if (this.position !== undefined) {
42
- tooltipNode.position = this.position;
42
+ this.__updatePosition(tooltipNode, this.position);
43
43
  }
44
44
 
45
45
  if (this.shouldShow !== undefined) {
@@ -48,7 +48,7 @@ export class TooltipController extends SlotController {
48
48
  }
49
49
 
50
50
  /**
51
- * Set a context object to be used by text generator.
51
+ * Set a context object to be used by generator.
52
52
  * @param {object} context
53
53
  */
54
54
  setContext(context) {
@@ -93,10 +93,7 @@ export class TooltipController extends SlotController {
93
93
  setPosition(position) {
94
94
  this.position = position;
95
95
 
96
- const tooltipNode = this.node;
97
- if (tooltipNode) {
98
- tooltipNode.position = position;
99
- }
96
+ this.__updatePosition(this.node, position);
100
97
  }
101
98
 
102
99
  /**
@@ -125,4 +122,11 @@ export class TooltipController extends SlotController {
125
122
  tooltipNode.target = target;
126
123
  }
127
124
  }
125
+
126
+ /** @private */
127
+ __updatePosition(node, position) {
128
+ if (node && !node.hasAttribute('position')) {
129
+ node.position = position;
130
+ }
131
+ }
128
132
  }