镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add lang property reflection to JSDOMParser - #1035

Open
josuesto wants to merge 1 commit into
mozilla:mainfrom
josuesto:fix/jsdomparser-lang
Open

josuesto wants to merge 1 commit into
mozilla:mainfrom
josuesto:fix/jsdomparser-lang

Conversation

@josuesto

@josuesto josuesto commented Oct 8, 2026

Copy link
Copy Markdown

Fixes #1026.

JSDOMParser keeps the lang attribute, but its elements have no lang property. For <html lang="en">, document.documentElement.lang returns undefined. Assigning .lang also leaves the attribute unchanged.

Add a getter and setter using the existing attribute-accessor pattern. Missing and empty values return an empty string. Attribute changes and property changes stay in sync, including on created elements. Readability's article language extraction is unchanged.

Add regression tests for present, missing and empty values, case preservation, attribute updates/removal, child elements and serialization. Add an Unreleased changelog entry.

Related earlier work: #1028, which was withdrawn.

Validation on Windows/Node v24.13.1: npm test passes all 1,991 tests; npm run lint passes. The seven new cases fail before the accessor is added. An independent comparison with the locked jsdom dependency passes all twelve checks after the fix.

AI assistance: Codex helped prepare the code and tests.

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.

JSDOMParser: Element is missing a lang accessor

1 participant