From ad7805e5d12f30d72be664f1f9379e0eff67ca40 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Mon, 16 Oct 2017 17:49:57 -0700 Subject: [PATCH] Check that document selectors are actually simple selectors Checking for `/deep/` and `::shadow` is not enough Fixes #4885 --- src/lib/style-transformer.html | 2 +- test/runner.html | 6 ++- test/unit/custom-style-transformed.html | 52 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 test/unit/custom-style-transformed.html diff --git a/src/lib/style-transformer.html b/src/lib/style-transformer.html index 90733c897d..caf8ddd710 100644 --- a/src/lib/style-transformer.html +++ b/src/lib/style-transformer.html @@ -311,7 +311,7 @@ }, _transformDocumentSelector: function(selector) { - return selector.match(SCOPE_JUMP) ? + return (selector.match(SCOPE_JUMP) || selector.match(SIMPLE_SELECTOR_SEP) )? this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR); }, diff --git a/test/runner.html b/test/runner.html index 3d0b095ea2..a5a6803e73 100644 --- a/test/runner.html +++ b/test/runner.html @@ -98,7 +98,11 @@ 'unit/dir.html', 'unit/dir.html?dom=shadow', 'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true', - 'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow' + 'unit/dir.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow', + 'unit/custom-style-transformed.html', + 'unit/custom-style-transformed.html?dom=shadow', + 'unit/custom-style-transformed.html?lazyRegister=true&useNativeCSSProperties=true', + 'unit/custom-style-transformed.html?lazyRegister=true&useNativeCSSProperties=true&dom=shadow' ]; if (window.customElements || document.registerElement) { diff --git a/test/unit/custom-style-transformed.html b/test/unit/custom-style-transformed.html new file mode 100644 index 0000000000..88de82cd79 --- /dev/null +++ b/test/unit/custom-style-transformed.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file