-
Notifications
You must be signed in to change notification settings - Fork 879
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
Don't clone nodes as part of the debug event logger #2635
Conversation
Writing it this way will do even less work (and no side effects) even in dev mode, unless the page has opted in.
🦋 Changeset detectedLatest commit: 18a0074 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
packages/lit-html/src/lit-html.ts
Outdated
const shouldEmit = (window as unknown as DebugLoggingWindow) | ||
.emitLitDebugLogEvents; | ||
if (shouldEmit) { | ||
return undefined; |
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.
Should the condition here be inverted?
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.
Eep, yes! I even got this right in the other location.
packages/lit-html/src/lit-html.ts
Outdated
const shouldEmit = (window as unknown as DebugLoggingWindow) | ||
.emitLitDebugLogEvents; | ||
if (shouldEmit) { | ||
return undefined; | ||
} | ||
return (event: LitUnstable.DebugLog.Entry) => { |
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.
Do you think it's that much better to be lazier here rather than removing the clone() calls? Why does the element need to be cloned in the first place? I think that could still fail in some cases when the event are enabled.
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.
Hm, yeah, good point, any event log subscribers that want copies of previous committed values would still synchronously get access to those values, so they could do the clone themselves if necessary
Integrations that need to clone nodes can do so themselves
Fixes #2632