diff options
Diffstat (limited to 'theme-compiler')
3 files changed, 31 insertions, 9 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java b/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java index cb7b0ac8a8..6b5c5538a4 100644 --- a/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java +++ b/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java @@ -32,18 +32,16 @@ public class ParentSelectorHandler { ArrayList<String> newList = new ArrayList<String>(block .getSelectorList().size()); BlockNode parentBlock = (BlockNode) parentNode; - for (final String s : block.getSelectorList()) { - - if (s.contains("&")) { - for (final String parentSelector : parentBlock - .getSelectorList()) { + for (final String parentSelector : parentBlock.getSelectorList()) { + for (final String s : block.getSelectorList()) { + if (s.contains("&")) { newList.add(s.replace("&", parentSelector)); isParentSelector = true; + } else { + newList.add(parentSelector + " " + s); } - } } - if (isParentSelector) { block.setSelectorList(newList); Node oldparent = block.getParentNode(); diff --git a/theme-compiler/tests/resources/css/parent-selector.css b/theme-compiler/tests/resources/css/parent-selector.css index e7e37e92ab..1aa389f593 100644 --- a/theme-compiler/tests/resources/css/parent-selector.css +++ b/theme-compiler/tests/resources/css/parent-selector.css @@ -31,6 +31,14 @@ body.firefox a { color: blue; } -.part.one, .part.two { +.part.one, .part.two, .part .non-parent { + color: blue; +} + +.root .part.one, .root .part .non-parent, .root .part2.one, .root .part2 .non-parent { + color: blue; +} + +.root2 .part .one, .root2 .part .non-parent, .root2 .part2 .one, .root2 .part2 .non-parent { color: blue; }
\ No newline at end of file diff --git a/theme-compiler/tests/resources/scss/parent-selector.scss b/theme-compiler/tests/resources/scss/parent-selector.scss index 68f66a4a27..c0ef46afb3 100644 --- a/theme-compiler/tests/resources/scss/parent-selector.scss +++ b/theme-compiler/tests/resources/scss/parent-selector.scss @@ -27,7 +27,23 @@ a { } .part { - &.one, &.two { + &.one, &.two, .non-parent { color: blue; } +} + +.root { + .part, .part2 { + &.one, .non-parent { + color: blue; + } + } +} + +.root2 { + .part, .part2 { + .one, .non-parent { + color: blue; + } + } }
\ No newline at end of file |