@lekoala/date-picker 0.5.0 → 0.5.2

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/src/messages.js CHANGED
@@ -28,4 +28,16 @@ export function getDefaultMessages() {
28
28
  /** @param {Partial<typeof DEFAULT_MESSAGES>} messages */
29
29
  export function setDefaultMessages(messages) {
30
30
  defaults = { ...defaults, ...messages };
31
+ for (const listener of listeners) listener();
32
+ }
33
+
34
+ /** @type {Set<() => void>} */
35
+ const listeners = new Set();
36
+
37
+ /** @param {() => void} listener */
38
+ export function subscribeDefaultMessages(listener) {
39
+ listeners.add(listener);
40
+ return () => {
41
+ listeners.delete(listener);
42
+ };
31
43
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Replay properties assigned before custom-element definition through their setters.
3
+ * Call only once the element is ready to accept the listed properties.
4
+ * @param {HTMLElement} element
5
+ * @param {string[]} properties
6
+ */
7
+ export function upgradeProperties(element, properties) {
8
+ for (const property of properties) {
9
+ if (!Object.hasOwn(element, property)) continue;
10
+ const value = Reflect.get(element, property);
11
+ Reflect.deleteProperty(element, property);
12
+ Reflect.set(element, property, value);
13
+ }
14
+ }