fix(mock-doc): updated node.prepend to work even if there are no existing children #6640
Conversation
…o insert the new child before
|
@kyleMessnerLillyContractor thanks for this. 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 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 |
…only attempt to add globalStyles when hydrating if the option is set to true
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. |
What is the current behavior?
If you call
node.prependon aMockNodewith no children then it will not prepend anything becausefirstChildisnullGitHub Issue Number: #6639
What is the new behavior?
Fixes #6639
node.prependnow always callsinsertBeforeregardless of whether or notfirstChildis aMockNodeornull. This is fine because the eventualinsertBeforefunction acceptsnullvalues for this parameter. This now also more closely matches the spec for the nativenode.prepend.Documentation
Does this introduce a breaking change?
If there is code relying on
node.prependnot inserting anything in elements with no existing children then the code will be broken by this change.Testing
npm run testpassesOther information