Skip to content

Loading…

custom-style containing '/deep/' or '::shadow' produces an SyntaxError in Firefox #2263

Closed
urandom opened this Issue · 4 comments

2 participants

@urandom

The problem occurs when the rule is passed to the Element.prototype.matches function.
Firefox throws the following:

SyntaxError: An invalid or illegal string was specified

The location of the error is in Polymer.StyleProperties.propertyDataFromStyles, when the matchesSelector is called on the rule. The rule with which I reproduce it is 'body /deep/ *', but any rule which contains /deep/ and ::shadow will trigger the error.

Before the custom-style element, the html contains both the script for webcomponents-lite.min.js, as well as the import for polymer.html.

@urandom

Some additions:
1. The rules must have custom properties, or the previous check (propertyInfo.properties) in the if will return false and the error won't be triggered
2. The problem also occurs in polymer 1.1. In it, rule.transformedSelector is undefined

@sorvell sorvell self-assigned this
@sorvell sorvell added the p1 label
@sorvell
Owner

We're going to fix this to avoid the exception, however, using /deep/ to define custom properties is not something the custom property shim has good support for. Only elements in the document scope (not shady or shadow-roots) will get the custom properties.

This is due to how Polymer's custom property shim is designed to work and is not likely to change. Instead, a property value is intended to inherit down the dom tree.

@sorvell
Owner

A selector like body /deep/ * should just be replaced with :root. I will effectively do the same thing.

@sorvell sorvell closed this issue from a commit
@sorvell sorvell Fixes #2263: ensure custom-style can parse variable definitions in su…
…pported selectors (e.g. /deep/) without exception due to unknown css.
894492b
@sorvell sorvell closed this in 894492b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.