Skip to content

Add scroll/scrollend listeners and scrollTop/scrollLeft attributes#146

Open
mikesol wants to merge 1 commit into
mainfrom
feat/scroll-event-and-scrolltop
Open

Add scroll/scrollend listeners and scrollTop/scrollLeft attributes#146
mikesol wants to merge 1 commit into
mainfrom
feat/scroll-event-and-scrolltop

Conversation

@mikesol

@mikesol mikesol commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds scroll and scrollend event listeners (from CSSOM View spec)
  • Adds scrollTop and scrollLeft as Number-typed attributes
  • Fixes a pre-existing codegen bug: pathLength and path-length in SVG were generating duplicate pathLength_ definitions

Details

scroll/scrollend events — Added cssom-view-1.json to the HTML event sources. The events are typed as Event (same as resize, load, etc.).

scrollTop/scrollLeft — These are DOM properties (not HTML attributes), so setAttribute doesn't work on them. Two changes:

  1. Main.purs fixHTML: adds scrollTop/scrollLeft as TypeNumber attributes on the Element interface
  2. DOMInterpret.purs: special-cases scrollTop/scrollLeft in setPropEffect to call Web.DOM.Element.setScrollTop/setScrollLeft directly

Usage:

import Deku.DOM.Attributes (scrollTop_, scrollLeft_)
import Deku.DOM.Listeners (scroll, scroll_)

D.div
  [ scrollTop_ 100.0
  , scroll_ \_ -> log "scrolled"
  ]
  [ ... ]

Bug fix (bonus)

nubBy in Parse.purs was deduplicating attributes by raw name (e.g. "path-length") rather than by generated identifier ("pathLength"). Combined with fixSVG checking raw names against a generated-name list (svgPresentationMembers uses camelCase), this produced a duplicate pathLength_ definition in Deku.DOM.SVG.Attributes when codegen was re-run against current webref data.

Fixed by:

  • Parse.purs: nubBy index instead of nubBy name
  • fixSVG: check existence by generated identifier (after unSnake), not raw name

🤖 Generated with Claude Code

- Add cssom-view-1 events source to HTML codegen: generates `scroll`,
  `scrollend`, and de-duplicates `resize` from the CSSOM View spec
- Add cssom-view-1 idlparsed source so interface resolution picks up
  Element extensions from that spec
- Add fixHTML to Main.purs: manually adds scrollTop and scrollLeft as
  TypeNumber attributes (DOM properties, not HTML attributes) to the
  Element interface
- Add special-case handling in DOMInterpret.setPropEffect for scrollTop
  and scrollLeft, using Web.DOM.Element.setScrollTop/setScrollLeft
  (DOM property assignment, not setAttribute)
- Fix EventDef.src to be Maybe to handle cssom-view-1 events without src
- Fix Parse.purs attribute deduplication: use nubBy index (generated
  identifier) instead of nubBy name (raw attribute name) to correctly
  deduplicate e.g. pathLength vs path-length
- Fix fixSVG duplicate-check to compare by generated identifier, not raw
  name: this eliminates the duplicate pathLength_ definition that would
  otherwise arise in Deku.DOM.SVG.Attributes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant