Skip to content

Commit

Permalink
fix(ui5-page): fix createElement error caused by adding new style pro…
Browse files Browse the repository at this point in the history
…perty in the constructor (#9998)

Custom element must not gain any attributes or children in the constructor,
as this violates the expectations of consumers who use the createElement or createElementNS methods.

Fixes #9981
  • Loading branch information
nikoletavnv authored Oct 11, 2024
1 parent 538d830 commit fd402e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/fiori/src/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class Page extends UI5Element {

constructor() {
super();
}

onEnterDOM(): void {
this.style.setProperty(getScopedVarName("--_ui5-page-animation-duration"), getAnimationMode() === AnimationMode.None ? "0s" : "0.35s");
}

Expand Down
15 changes: 14 additions & 1 deletion packages/fiori/test/specs/Page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Page general interaction", () => {
timeoutMsg: "expected footer to not be visible after 500ms"
});
});

it("tests animation off footer toggling" , async () => {
await browser.url(`test/pages/Page.html?sap-ui-animationMode=none`);

Expand All @@ -43,4 +43,17 @@ describe("Page general interaction", () => {

assert.ok(!(await footer.isDisplayedInViewport()), "Footer should not be visible.");
});

it("createElement does not throw exception", async () => {
let result;

result = await browser.executeAsync(async (done) => {
const p = document.createElement("ui5-page");
// createElement throws exception during attachInternals() call but the exception can not be caught
// so we check if the _internals property is added to the page object
done(p._internals !== undefined);
});

assert.ok( result, "No exception should be thrown");
});
});

0 comments on commit fd402e4

Please sign in to comment.