@ui5/webcomponents-base 2.23.0-rc.1 → 2.23.0

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/dist/Render.d.ts CHANGED
@@ -7,6 +7,14 @@ type BeforeComponentRenderCallback = (webComponent: UI5Element) => void;
7
7
  * @returns {Promise}
8
8
  */
9
9
  declare const renderDeferred: (webComponent: UI5Element) => Promise<void>;
10
+ /**
11
+ * Register all web components attached to the DOM
12
+ */
13
+ declare const registerElement: (webComponent: UI5Element) => void;
14
+ /**
15
+ * Unregister all web components detached from the DOM
16
+ */
17
+ declare const unregisterElement: (webComponent: UI5Element) => void;
10
18
  /**
11
19
  * Renders a component synchronously and adds it to the registry of rendered components
12
20
  *
@@ -44,4 +52,4 @@ declare const reRenderAllUI5Elements: (filters?: {
44
52
  }) => Promise<void>;
45
53
  declare const attachBeforeComponentRender: (listener: BeforeComponentRenderCallback) => void;
46
54
  declare const detachBeforeComponentRender: (listener: BeforeComponentRenderCallback) => void;
47
- export { renderDeferred, renderImmediately, cancelRender, renderFinished, reRenderAllUI5Elements, attachBeforeComponentRender, detachBeforeComponentRender, };
55
+ export { renderDeferred, renderImmediately, cancelRender, registerElement, unregisterElement, renderFinished, reRenderAllUI5Elements, attachBeforeComponentRender, detachBeforeComponentRender, };
package/dist/Render.js CHANGED
@@ -20,6 +20,18 @@ const renderDeferred = async (webComponent) => {
20
20
  // Schedule a rendering task
21
21
  await scheduleRenderTask();
22
22
  };
23
+ /**
24
+ * Register all web components attached to the DOM
25
+ */
26
+ const registerElement = (webComponent) => {
27
+ registeredElements.add(webComponent);
28
+ };
29
+ /**
30
+ * Unregister all web components detached from the DOM
31
+ */
32
+ const unregisterElement = (webComponent) => {
33
+ registeredElements.delete(webComponent);
34
+ };
23
35
  /**
24
36
  * Renders a component synchronously and adds it to the registry of rendered components
25
37
  *
@@ -27,7 +39,7 @@ const renderDeferred = async (webComponent) => {
27
39
  */
28
40
  const renderImmediately = (webComponent) => {
29
41
  eventProvider.fireEvent("beforeComponentRender", webComponent);
30
- registeredElements.add(webComponent);
42
+ registerElement(webComponent);
31
43
  webComponent._render();
32
44
  };
33
45
  /**
@@ -37,7 +49,7 @@ const renderImmediately = (webComponent) => {
37
49
  */
38
50
  const cancelRender = (webComponent) => {
39
51
  invalidatedWebComponents.remove(webComponent);
40
- registeredElements.delete(webComponent);
52
+ unregisterElement(webComponent);
41
53
  };
42
54
  /**
43
55
  * Schedules a rendering task, if not scheduled already
@@ -139,5 +151,5 @@ const attachBeforeComponentRender = (listener) => {
139
151
  const detachBeforeComponentRender = (listener) => {
140
152
  eventProvider.detachEvent("beforeComponentRender", listener);
141
153
  };
142
- export { renderDeferred, renderImmediately, cancelRender, renderFinished, reRenderAllUI5Elements, attachBeforeComponentRender, detachBeforeComponentRender, };
154
+ export { renderDeferred, renderImmediately, cancelRender, registerElement, unregisterElement, renderFinished, reRenderAllUI5Elements, attachBeforeComponentRender, detachBeforeComponentRender, };
143
155
  //# sourceMappingURL=Render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Render.js","sourceRoot":"","sources":["../src/Render.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM1D,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAc,CAAC;AACjD,MAAM,aAAa,GAAG,IAAI,aAAa,EAAoB,CAAC;AAE5D,MAAM,wBAAwB,GAAG,IAAI,WAAW,EAAE,CAAC,CAAC,uCAAuC;AAE3F,IAAI,iBAA4C,EAC/C,wBAAoD,CAAC;AAEtD,IAAI,qBAA0C,CAAC;AAE/C,IAAI,YAAkC,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,cAAc,GAAG,KAAK,EAAE,YAAwB,EAAE,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port { getAllRegisteredTags } from \"./CustomElementsRegistry.js\";\nimport { isRtlAware } from \"./locale/RTLAwareRegistry.js\";\nimport type UI5Element from \"./UI5Element.js\";\nimport type { PromiseResolve, Timeout } from \"./types.js\";\n\ntype BeforeComponentRenderCallback = (webComponent: UI5Element) => void;\n\nconst registeredElements = new Set<UI5Element>();\nconst eventProvider = new EventProvider<UI5Element, void>();\n\nconst invalidatedWebComponents = new RenderQueue(); // Queue for invalidated web components\n\nlet renderTaskPromise: Promise<void> | undefined,\n\trenderTaskPromiseResolve: PromiseResolve | undefined;\n\nlet mutationObserverTimer: Timeout | undefined;\n\nlet queuePromise: Promise<void> | null;\n\n/**\n * Schedules a render task (if not already scheduled) to render the component\n *\n * @param webComponent\n * @returns {Promise}\n */\nconst renderDeferred = async (webComponent: UI5Element) => {\n\t// Enqueue the web component\n\tinvalidatedWebComponents.add(webComponent);\n\n\t// Schedule a rendering task\n\tawait scheduleRenderTask();\n};\n\n/**\n * Renders a component synchronously and adds it to the registry of rendered components\n *\n * @param webComponent\n */\nconst renderImmediately = (webComponent: UI5Element) => {\n\teventProvider.fireEvent(\"beforeComponentRender\", webComponent);\n\tregisteredElements.add(webComponent);\n\twebComponent._render();\n};\n\n/**\n * Cancels the rendering of a component, if awaiting to be rendered, and removes it from the registry of rendered components\n *\n * @param webComponent\n */\nconst cancelRender = (webComponent: UI5Element) => {\n\tinvalidatedWebComponents.remove(webComponent);\n\tregisteredElements.delete(webComponent);\n};\n\n/**\n * Schedules a rendering task, if not scheduled already\n */\nconst scheduleRenderTask = async () => {\n\tif (!queuePromise) {\n\t\tqueuePromise = new Promise<void>(resolve => {\n\t\t\twindow.requestAnimationFrame(() => {\n\t\t\t\t// Render all components in the queue\n\n\t\t\t\t// console.log(`--------------------RENDER TASK START------------------------------`); // eslint-disable-line\n\t\t\t\tinvalidatedWebComponents.process(renderImmediately);\n\t\t\t\t// console.log(`--------------------RENDER TASK END------------------------------`); // eslint-disable-line\n\n\t\t\t\t// Resolve the promise so that callers of renderDeferred can continue\n\t\t\t\tqueuePromise = null;\n\t\t\t\tresolve();\n\n\t\t\t\t// Wait for Mutation observer before the render task is considered finished\n\t\t\t\tif (!mutationObserverTimer) {\n\t\t\t\t\tmutationObserverTimer = setTimeout(() => {\n\t\t\t\t\t\tmutationObserverTimer = undefined;\n\t\t\t\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\t\t\t\t_resolveTaskPromise();\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 200);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tawait queuePromise;\n};\n\n/**\n * return a promise that will be resolved once all invalidated web components are rendered\n */\nconst whenDOMUpdated = () => {\n\tif (renderTaskPromise) {\n\t\treturn renderTaskPromise;\n\t}\n\n\trenderTaskPromise = new Promise<void>(resolve => {\n\t\trenderTaskPromiseResolve = resolve;\n\t\twindow.requestAnimationFrame(() => {\n\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\trenderTaskPromise = undefined;\n\t\t\t\tresolve();\n\t\t\t}\n\t\t});\n\t});\n\n\treturn renderTaskPromise;\n};\n\nconst whenAllCustomElementsAreDefined = () => {\n\tconst definedPromises = getAllRegisteredTags().map(tag => customElements.whenDefined(tag));\n\treturn Promise.all(definedPromises);\n};\n\nconst renderFinished = async () => {\n\tawait whenAllCustomElementsAreDefined();\n\tawait whenDOMUpdated();\n};\n\nconst _resolveTaskPromise = () => {\n\tif (!invalidatedWebComponents.isEmpty()) {\n\t\t// More updates are pending. Resolve will be called again\n\t\treturn;\n\t}\n\n\tif (renderTaskPromiseResolve) {\n\t\trenderTaskPromiseResolve();\n\t\trenderTaskPromiseResolve = undefined;\n\t\trenderTaskPromise = undefined;\n\t}\n};\n\n/**\n * Re-renders all UI5 Elements on the page, with the option to specify filters to rerender only some components.\n *\n * Usage:\n * reRenderAllUI5Elements() -> re-renders all components\n * reRenderAllUI5Elements({tag: \"ui5-button\"}) -> re-renders only instances of ui5-button\n * reRenderAllUI5Elements({rtlAware: true}) -> re-renders only rtlAware components\n * reRenderAllUI5Elements({languageAware: true}) -> re-renders only languageAware components\n * reRenderAllUI5Elements({themeAware: true}) -> re-renders only themeAware components\n * reRenderAllUI5Elements({rtlAware: true, languageAware: true}) -> re-renders components that are rtlAware or languageAware\n * etc...\n *\n * @public\n * @param {object|undefined} filters - Object with keys that can be \"rtlAware\" or \"languageAware\"\n * @returns {Promise<void>}\n */\nconst reRenderAllUI5Elements = async (filters?: {tag?: string, rtlAware?: boolean, languageAware?: boolean, themeAware?: boolean}) => {\n\tregisteredElements.forEach((element: UI5Element) => {\n\t\tconst ctor = element.constructor as typeof UI5Element;\n\t\tconst tag = ctor.getMetadata().getTag();\n\t\tconst rtlAware = isRtlAware(ctor);\n\t\tconst languageAware = ctor.getMetadata().isLanguageAware();\n\t\tconst themeAware = ctor.getMetadata().isThemeAware();\n\t\tif (!filters || (filters.tag === tag) || (filters.rtlAware && rtlAware) || (filters.languageAware && languageAware) || (filters.themeAware && themeAware)) {\n\t\t\trenderDeferred(element);\n\t\t}\n\t});\n\tawait renderFinished();\n};\n\nconst attachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.attachEvent(\"beforeComponentRender\", listener);\n};\n\nconst detachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.detachEvent(\"beforeComponentRender\", listener);\n};\n\nexport {\n\trenderDeferred,\n\trenderImmediately,\n\tcancelRender,\n\trenderFinished,\n\treRenderAllUI5Elements,\n\tattachBeforeComponentRender,\n\tdetachBeforeComponentRender,\n};\n"]}
1
+ {"version":3,"file":"Render.js","sourceRoot":"","sources":["../src/Render.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM1D,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,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;IACF,CAAC,CAAC,CAAC;IACH,MAAM,cAAc,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,QAAuC,EAAE,EAAE;IAC/E,aAAa,CAAC,WAAW,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,QAAuC,EAAE,EAAE;IAC/E,aAAa,CAAC,WAAW,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,GAC3B,CAAC","sourcesContent":["import EventProvider from \"./EventProvider.js\";\nimport RenderQueue from \"./RenderQueue.js\";\nimport { getAllRegisteredTags } from \"./CustomElementsRegistry.js\";\nimport { isRtlAware } from \"./locale/RTLAwareRegistry.js\";\nimport type UI5Element from \"./UI5Element.js\";\nimport type { PromiseResolve, Timeout } from \"./types.js\";\n\ntype BeforeComponentRenderCallback = (webComponent: UI5Element) => void;\n\nconst registeredElements = new Set<UI5Element>();\nconst eventProvider = new EventProvider<UI5Element, void>();\n\nconst invalidatedWebComponents = new RenderQueue(); // Queue for invalidated web components\n\nlet renderTaskPromise: Promise<void> | undefined,\n\trenderTaskPromiseResolve: PromiseResolve | undefined;\n\nlet mutationObserverTimer: Timeout | undefined;\n\nlet queuePromise: Promise<void> | null;\n\n/**\n * Schedules a render task (if not already scheduled) to render the component\n *\n * @param webComponent\n * @returns {Promise}\n */\nconst renderDeferred = async (webComponent: UI5Element) => {\n\t// Enqueue the web component\n\tinvalidatedWebComponents.add(webComponent);\n\n\t// Schedule a rendering task\n\tawait scheduleRenderTask();\n};\n\n/**\n * Register all web components attached to the DOM\n */\nconst registerElement = (webComponent: UI5Element) => {\n\tregisteredElements.add(webComponent);\n};\n\n/**\n * Unregister all web components detached from the DOM\n */\nconst unregisterElement = (webComponent: UI5Element) => {\n\tregisteredElements.delete(webComponent);\n};\n\n/**\n * Renders a component synchronously and adds it to the registry of rendered components\n *\n * @param webComponent\n */\nconst renderImmediately = (webComponent: UI5Element) => {\n\teventProvider.fireEvent(\"beforeComponentRender\", webComponent);\n\tregisterElement(webComponent);\n\twebComponent._render();\n};\n\n/**\n * Cancels the rendering of a component, if awaiting to be rendered, and removes it from the registry of rendered components\n *\n * @param webComponent\n */\nconst cancelRender = (webComponent: UI5Element) => {\n\tinvalidatedWebComponents.remove(webComponent);\n\tunregisterElement(webComponent);\n};\n\n/**\n * Schedules a rendering task, if not scheduled already\n */\nconst scheduleRenderTask = async () => {\n\tif (!queuePromise) {\n\t\tqueuePromise = new Promise<void>(resolve => {\n\t\t\twindow.requestAnimationFrame(() => {\n\t\t\t\t// Render all components in the queue\n\n\t\t\t\t// console.log(`--------------------RENDER TASK START------------------------------`); // eslint-disable-line\n\t\t\t\tinvalidatedWebComponents.process(renderImmediately);\n\t\t\t\t// console.log(`--------------------RENDER TASK END------------------------------`); // eslint-disable-line\n\n\t\t\t\t// Resolve the promise so that callers of renderDeferred can continue\n\t\t\t\tqueuePromise = null;\n\t\t\t\tresolve();\n\n\t\t\t\t// Wait for Mutation observer before the render task is considered finished\n\t\t\t\tif (!mutationObserverTimer) {\n\t\t\t\t\tmutationObserverTimer = setTimeout(() => {\n\t\t\t\t\t\tmutationObserverTimer = undefined;\n\t\t\t\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\t\t\t\t_resolveTaskPromise();\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 200);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tawait queuePromise;\n};\n\n/**\n * return a promise that will be resolved once all invalidated web components are rendered\n */\nconst whenDOMUpdated = () => {\n\tif (renderTaskPromise) {\n\t\treturn renderTaskPromise;\n\t}\n\n\trenderTaskPromise = new Promise<void>(resolve => {\n\t\trenderTaskPromiseResolve = resolve;\n\t\twindow.requestAnimationFrame(() => {\n\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\trenderTaskPromise = undefined;\n\t\t\t\tresolve();\n\t\t\t}\n\t\t});\n\t});\n\n\treturn renderTaskPromise;\n};\n\nconst whenAllCustomElementsAreDefined = () => {\n\tconst definedPromises = getAllRegisteredTags().map(tag => customElements.whenDefined(tag));\n\treturn Promise.all(definedPromises);\n};\n\nconst renderFinished = async () => {\n\tawait whenAllCustomElementsAreDefined();\n\tawait whenDOMUpdated();\n};\n\nconst _resolveTaskPromise = () => {\n\tif (!invalidatedWebComponents.isEmpty()) {\n\t\t// More updates are pending. Resolve will be called again\n\t\treturn;\n\t}\n\n\tif (renderTaskPromiseResolve) {\n\t\trenderTaskPromiseResolve();\n\t\trenderTaskPromiseResolve = undefined;\n\t\trenderTaskPromise = undefined;\n\t}\n};\n\n/**\n * Re-renders all UI5 Elements on the page, with the option to specify filters to rerender only some components.\n *\n * Usage:\n * reRenderAllUI5Elements() -> re-renders all components\n * reRenderAllUI5Elements({tag: \"ui5-button\"}) -> re-renders only instances of ui5-button\n * reRenderAllUI5Elements({rtlAware: true}) -> re-renders only rtlAware components\n * reRenderAllUI5Elements({languageAware: true}) -> re-renders only languageAware components\n * reRenderAllUI5Elements({themeAware: true}) -> re-renders only themeAware components\n * reRenderAllUI5Elements({rtlAware: true, languageAware: true}) -> re-renders components that are rtlAware or languageAware\n * etc...\n *\n * @public\n * @param {object|undefined} filters - Object with keys that can be \"rtlAware\" or \"languageAware\"\n * @returns {Promise<void>}\n */\nconst reRenderAllUI5Elements = async (filters?: {tag?: string, rtlAware?: boolean, languageAware?: boolean, themeAware?: boolean}) => {\n\tregisteredElements.forEach((element: UI5Element) => {\n\t\tconst ctor = element.constructor as typeof UI5Element;\n\t\tconst tag = ctor.getMetadata().getTag();\n\t\tconst rtlAware = isRtlAware(ctor);\n\t\tconst languageAware = ctor.getMetadata().isLanguageAware();\n\t\tconst themeAware = ctor.getMetadata().isThemeAware();\n\t\tif (!filters || (filters.tag === tag) || (filters.rtlAware && rtlAware) || (filters.languageAware && languageAware) || (filters.themeAware && themeAware)) {\n\t\t\trenderDeferred(element);\n\t\t}\n\t});\n\tawait renderFinished();\n};\n\nconst attachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.attachEvent(\"beforeComponentRender\", listener);\n};\n\nconst detachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.detachEvent(\"beforeComponentRender\", listener);\n};\n\nexport {\n\trenderDeferred,\n\trenderImmediately,\n\tcancelRender,\n\tregisterElement,\n\tunregisterElement,\n\trenderFinished,\n\treRenderAllUI5Elements,\n\tattachBeforeComponentRender,\n\tdetachBeforeComponentRender,\n};\n"]}
@@ -6,7 +6,7 @@ import UI5ElementMetadata from "./UI5ElementMetadata.js";
6
6
  import EventProvider from "./EventProvider.js";
7
7
  import updateShadowRoot from "./updateShadowRoot.js";
8
8
  import { shouldIgnoreCustomElement } from "./IgnoreCustomElements.js";
9
- import { renderDeferred, renderImmediately, cancelRender, } from "./Render.js";
9
+ import { renderDeferred, renderImmediately, cancelRender, unregisterElement, registerElement, } from "./Render.js";
10
10
  import { registerTag, isTagRegistered, recordTagRegistrationFailure } from "./CustomElementsRegistry.js";
11
11
  import { observeDOMNode, unobserveDOMNode } from "./DOMObserver.js";
12
12
  import { skipOriginalEvent } from "./config/NoConflict.js";
@@ -50,11 +50,13 @@ const defaultConverter = {
50
50
  if (type === Boolean) {
51
51
  return value ? "" : null;
52
52
  }
53
- // don't set attributes for arrays and objects
53
+ // Don't reflect arrays and objects to the DOM. Attributes exist for CSS selectors
54
+ // (which don't apply to objects/arrays) and for debugging via the Elements panel
55
+ // (devs will use the console with property access for these). Declarative
56
+ // attribute -> property is still supported via fromAttribute (JSON.parse).
54
57
  if (type === Object || type === Array) {
55
- return JSON.stringify(value);
58
+ return null;
56
59
  }
57
- // object, array, other
58
60
  if (value === null || value === undefined) {
59
61
  return null;
60
62
  }
@@ -202,6 +204,7 @@ class UI5Element extends HTMLElement {
202
204
  }
203
205
  }
204
206
  const ctor = this.constructor;
207
+ registerElement(this);
205
208
  this.setAttribute(ctor.getMetadata().getPureTag(), "");
206
209
  if (ctor.getMetadata().supportsF6FastNavigation() && !this.hasAttribute("data-sap-ui-fastnavgroup")) {
207
210
  this.setAttribute("data-sap-ui-fastnavgroup", "true");
@@ -216,6 +219,11 @@ class UI5Element extends HTMLElement {
216
219
  if (!ctor.asyncFinished) {
217
220
  await ctor._definePromise;
218
221
  }
222
+ // Skip rendering while a language change is in progress to avoid rendering with not fully loaded locale data.
223
+ // Once the locale data is loaded, the language-aware component will be re-rendered.
224
+ if (ctor.getMetadata().isLanguageAware() && getLanguageChangePending()) {
225
+ return;
226
+ }
219
227
  if (!this._inDOM) { // Component removed from DOM while _processChildren was running
220
228
  return;
221
229
  }
@@ -223,6 +231,15 @@ class UI5Element extends HTMLElement {
223
231
  this._domRefReadyPromise._deferredResolve();
224
232
  this._fullyConnected = true;
225
233
  this.onEnterDOM();
234
+ if (this.hasAttribute("autofocus")) {
235
+ // Honor the global `autofocus` HTML attribute. Done manually because
236
+ // Firefox/Safari close the autofocus window at end-of-parse, before
237
+ // async UI5 components have rendered their shadow DOM. Per HTML spec,
238
+ // only the first element with `autofocus` in document order wins.
239
+ requestAnimationFrame(() => {
240
+ this.focus();
241
+ });
242
+ }
226
243
  }
227
244
  get definePromise() {
228
245
  const ctor = this.constructor;
@@ -248,6 +265,7 @@ class UI5Element extends HTMLElement {
248
265
  }
249
266
  this._domRefReadyPromise._deferredResolve();
250
267
  cancelRender(this);
268
+ unregisterElement(this);
251
269
  }
252
270
  /**
253
271
  * Called every time before the component renders.
@@ -514,6 +532,12 @@ class UI5Element extends HTMLElement {
514
532
  }
515
533
  const properties = ctor.getMetadata().getProperties();
516
534
  const propData = properties[name];
535
+ // Object and Array properties are not reflected to attributes. The attribute is only
536
+ // consumed as a declarative input (parsed via fromAttribute on attributeChangedCallback),
537
+ // so the framework must neither write nor remove it - leave any author-set attribute alone.
538
+ if (propData.type === Object || propData.type === Array) {
539
+ return;
540
+ }
517
541
  const attrName = camelToKebabCase(name);
518
542
  const converter = propData.converter || defaultConverter;
519
543
  if (DEV_MODE) {