fgnass / domino

Server-side DOM implementation based on Mozilla's dom.js
BSD 2-Clause "Simplified" License
769 stars 120 forks source link

css parser fails during style.setProperty() if variable name starts with "--" #175

Open bob-walters opened 3 years ago

bob-walters commented 3 years ago

Noticed in domino 2.1.6 via angular9 universal.

If someElement.style.setProperty(key, value) is called using a key which begins with "--" (i.e. custom CSS variables), the following parsing error is reported:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at TokenStream.LA (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/cssparser.js:810:1)
    at TokenStream.advance (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/cssparser.js:683:1)
    at Parser._readDeclarations (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/cssparser.js:3402:1)
    at Parser.parseStyleAttribute (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/cssparser.js:3581:1)
    at parseStyles (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/CSSStyleDeclaration.js:23:1)
    at CSSStyleDeclaration.value (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/node_modules/domino/lib/CSSStyleDeclaration.js:142:1)
    at AppComponent.<anonymous> (/Users/bobw/workspaces/te2/marketplace/frontend/dist/frontend/server/webpack:/src/app/app.component.ts:97:27)
    at Generator.next (<anonymous>)
....

Are custom CSS variables currently supported?

Burgov commented 3 years ago

there is already an issue for this: https://github.com/fgnass/domino/issues/165