Skip to content

fix(runtime): fix NotFoundError in addStyle function with referenceNode parent check - #6107

Merged
christian-bromann merged 2 commits into
stenciljs:mainfrom
hbeyan:fix/runtime_addStyle_not_found_error
Jan 25, 2025
Merged

christian-bromann merged 2 commits into
stenciljs:mainfrom
hbeyan:fix/runtime_addStyle_not_found_error

Conversation

@hbeyan

@hbeyan hbeyan commented Jan 20, 2025

Copy link
Copy Markdown
Contributor

What is the current behavior?

addStyle function causes NotFoundError in for some components in our micro front end app.

GitHub Issue Number: 6106

What is the new behavior?

referenceNode's parentNode is checked to prevent insertBefore throwing NotFoundError method.
If the referenceNode is not a direct child of the element receiving the styleNode as the child, referenceNode is not used.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

@hbeyan
hbeyan requested a review from a team as a code owner January 20, 2025 18:23
@christian-bromann

Copy link
Copy Markdown
Member

@hbeyan thanks for raising the issue. Mind adding a WebdriverIO test for this to ensure we don't regress on this?

@hbeyan

hbeyan commented Jan 23, 2025

Copy link
Copy Markdown
Contributor Author

@hbeyan thanks for raising the issue. Mind adding a WebdriverIO test for this to ensure we don't regress on this?

Unfortunately I can only reproduce the issue in micro front-end app, I wasn't able to reproduce it with WebdriverIO tests

@christian-bromann

Copy link
Copy Markdown
Member

, I wasn't able to reproduce it with WebdriverIO tests

Can you reproduce it on a Stencil Starter app? npm init stencil component exampleProject

@johnjenkins

Copy link
Copy Markdown
Contributor

I guess it's quite a logical check to do either way (that the parent node include the reference node)?

I don't really understand how it can happen ... it's looking for <link /> or <style /> elements in the head ... and nothing in the head can be nested... so it doesn't really make sense, but I guess there's no harm having an extra check

@hbeyan

hbeyan commented Jan 24, 2025

Copy link
Copy Markdown
Contributor Author

, I wasn't able to reproduce it with WebdriverIO tests

Can you reproduce it on a Stencil Starter app? npm init stencil component exampleProject

reproduction project is linked in the issue #6106

@christian-bromann christian-bromann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@christian-bromann
christian-bromann added this pull request to the merge queue Jan 25, 2025
@christian-bromann
christian-bromann removed this pull request from the merge queue due to a manual request Jan 25, 2025
@christian-bromann
christian-bromann merged commit 26ceed6 into stenciljs:main Jan 25, 2025
@johnjenkins johnjenkins mentioned this pull request May 6, 2026
1 of 2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants