Skip to content

fix(mock-doc): updated node.prepend to work even if there are no existing children #6640

Merged
johnjenkins merged 4 commits intostenciljs:mainfrom
kyleMessnerLillyContractor:main
Mar 19, 2026
Merged

fix(mock-doc): updated node.prepend to work even if there are no existing children #6640
johnjenkins merged 4 commits intostenciljs:mainfrom
kyleMessnerLillyContractor:main

Conversation

@kyleMessnerLillyContractor
Copy link
Copy Markdown
Contributor

@kyleMessnerLillyContractor kyleMessnerLillyContractor commented Mar 13, 2026

What is the current behavior?

If you call node.prepend on a MockNode with no children then it will not prepend anything because firstChild is null

GitHub Issue Number: #6639

What is the new behavior?

Fixes #6639

node.prepend now always calls insertBefore regardless of whether or not firstChild is a MockNode or null. This is fine because the eventual insertBefore function accepts null values for this parameter. This now also more closely matches the spec for the native node.prepend.

Documentation

Does this introduce a breaking change?

  • Yes
  • No

If there is code relying on node.prepend not inserting anything in elements with no existing children then the code will be broken by this change.

Testing

npm run test passes

Other information

@kyleMessnerLillyContractor kyleMessnerLillyContractor requested a review from a team as a code owner March 13, 2026 16:43
@johnjenkins
Copy link
Copy Markdown
Contributor

johnjenkins commented Mar 17, 2026

@kyleMessnerLillyContractor thanks for this.
The tests are failing due to SSR now prepending globalStyle as a <style> to all elements....

Whilst this is probably what's supposed to happen, I think the change might be too big to expect from a patch / fix.

i.e. if someone includes the whole of bootstrap in a globalStyle they'll now have millions of new LoC coming down the wire that they did not before when rendering <custom-list><custom-option>*100</custom-list>..

If you want this to go into a non-major version, I think you'll need to change a config option ... suggest addGlobalStyleToComponents - it's default is currently true < suggest you add a new default to be client or similar to retain the current behaviour

@kyleMessnerLillyContractor
Copy link
Copy Markdown
Contributor Author

If you want this to go into a non-major version, I think you'll need to change a config option ... suggest addGlobalStyleToComponents - it's default is currently true < suggest you add a new default to be client or similar to retain the current behaviour

Hopefully that is the correct way to extend that option. Let me know if I missed anything. I'll make a PR to update the site docs once this PR is ready to be merged.

@johnjenkins johnjenkins added this pull request to the merge queue Mar 19, 2026
Merged via the queue into stenciljs:main with commit cd22da5 Mar 19, 2026
69 checks passed
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.

bug: globalStyles not prepended to SSR rendered components

2 participants