Skip to content

Commit

Permalink
chore: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev committed Jan 10, 2025
1 parent 2624280 commit 336d4de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 2 additions & 6 deletions packages/base/src/UI5Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ abstract class UI5Element extends HTMLElement {
_internals: ElementInternals;
_individualSlot?: string;
_getRealDomRef?: () => HTMLElement;
_skipFirstRender?: boolean;

static template?: TemplateFunction;
static _metadata: UI5ElementMetadata;
Expand Down Expand Up @@ -235,9 +234,7 @@ abstract class UI5Element extends HTMLElement {
const ctor = this.constructor as typeof UI5Element;
if (ctor._needsShadowDOM()) {
const defaultOptions = { mode: "open" } as ShadowRootInit;
if (this.shadowRoot) { // if there is already a declarative shadow root, do not destroy it
this._skipFirstRender = true;
} else {
if (!this.shadowRoot) { // if there is already a declarative shadow root, do not destroy it
this.attachShadow({ ...defaultOptions, ...ctor.getMetadata().getShadowRootOptions() });
}

Expand Down Expand Up @@ -857,8 +854,7 @@ abstract class UI5Element extends HTMLElement {

// Update shadow root
if (ctor._needsShadowDOM()) {
updateShadowRoot(this, this._skipFirstRender);
this._skipFirstRender = false;
updateShadowRoot(this);
}
this._rendered = true;

Expand Down
8 changes: 3 additions & 5 deletions packages/base/src/updateShadowRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import getConstructableStyle from "./theming/getConstructableStyle.js";
import type UI5Element from "./UI5Element.js";

/**
* Updates the shadow root of a UI5Element (both CSS and HTML)
* Updates the shadow root of a UI5Element or its static area item
* @param element
*/
const updateShadowRoot = (element: UI5Element, skipDOMUpdate = false) => {
const updateShadowRoot = (element: UI5Element) => {
const ctor = element.constructor as typeof UI5Element;
const shadowRoot = element.shadowRoot;

Expand All @@ -15,9 +15,7 @@ const updateShadowRoot = (element: UI5Element, skipDOMUpdate = false) => {
}

shadowRoot.adoptedStyleSheets = getConstructableStyle(ctor);
if (!skipDOMUpdate) {
ctor.renderer(element, shadowRoot);
}
ctor.renderer(element, shadowRoot);
};

export default updateShadowRoot;

0 comments on commit 336d4de

Please sign in to comment.