-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(template-compiler): fix static listeners with deep paths #3807
Conversation
|
||
// Cloning here is necessary because `this.replace()` is destructive, and we might use the | ||
// node later during static content optimization | ||
expression = doStructuredClone(expression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really subtle bug – the code below is mutating the AST, which only becomes a problem later if we try to re-use it, which we do during the static content optimization, which is a second pass on top of the first pass we already did.
First pass:
data.push(codeGen.genEventListeners(listeners)); |
Second pass:
addDatabagProp(this.genEventListeners(node.listeners)); |
const doStructuredClone = | ||
typeof structuredClone === 'function' | ||
? structuredClone | ||
: (obj: any) => JSON.parse(JSON.stringify(obj)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually ran the Karma tests in Node 16 just to be safe.
Looks like the AST format changed... will need another look. |
Found a pre-existing issue: #3808 |
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.html
Outdated
Show resolved
Hide resolved
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.js
Outdated
Show resolved
Hide resolved
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.js
Outdated
Show resolved
Hide resolved
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.js
Outdated
Show resolved
Hide resolved
…ener/deepListener.html Co-authored-by: Eugene Kashida <ekashida@gmail.com>
…ener/deepListener.js Co-authored-by: Eugene Kashida <ekashida@gmail.com>
…ener/deepListener.js Co-authored-by: Eugene Kashida <ekashida@gmail.com>
…ener/deepListener.js Co-authored-by: Eugene Kashida <ekashida@gmail.com>
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.html
Outdated
Show resolved
Hide resolved
packages/@lwc/integration-karma/test/static-content/x/deepListener/deepListener.html
Outdated
Show resolved
Hide resolved
…ener/deepListener.html
…ener/deepListener.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, let's wait to see whether the ast changes are bueno
Details
Fixes #3804
Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?