fix: don't treat non-function on* props on custom elements as event handlers#5170
fix: don't treat non-function on* props on custom elements as event handlers#5170JoviDeCroock wants to merge 1 commit into
Conversation
…andlers Custom elements may expose non-event attributes starting with "on" (e.g. only-when-overflow). Only take the event-listener path when the new or old value is a function, or the element is not a custom element (no dash in its tag name). The typeof check short-circuits first, so regular event handlers pay no extra cost. Fixes #4085
| else if ( | ||
| name[0] == 'o' && | ||
| name[1] == 'n' && | ||
| (typeof value == 'function' || |
There was a problem hiding this comment.
short-circuit so there shouldn't be an extra cost for normal execution)
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Resultscreate10kduration
usedJSHeapSize
filter-listduration
usedJSHeapSize
hydrate1kduration
usedJSHeapSize
many-updatesduration
usedJSHeapSize
replace1kduration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
text-updateduration
usedJSHeapSize
tododuration
usedJSHeapSize
update10th1kduration
usedJSHeapSize
|
|
Size Change: +22 B (+0.14%) Total Size: 15.9 kB 📦 View Changed
ℹ️ View Unchanged
|
IMO, we shouldn't support this.
|
|
I mean, onlyOverflow for instance is a valid name for a prop and it runs into this issue. I think it's a non obvious footgun. I guess it has propagated in the ecosystem so we can live with it, tried to see if we had some easy fixes |
Custom elements may expose non-event attributes starting with "on" (e.g. only-when-overflow). Only take the event-listener path when the new or old value is a function, or the element is not a custom element (no dash in its tag name).
Fixes #4085
Co-Authored with GPT5.6-sol for tests