diff options
author | Marc Englund <marc@vaadin.com> | 2012-09-11 16:27:05 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-09-11 16:27:28 +0300 |
commit | c9e8218799152dd90bacb6c8b92b648a951aca24 (patch) | |
tree | 88838e0fdaf1257258d2e3d5eaffd7cb88819ab6 /theme-compiler/src/com/vaadin/sass/selector | |
parent | 6ccbb9e40ebb160d2bc1a57c5b5293c4f87d0b27 (diff) | |
download | vaadin-framework-c9e8218799152dd90bacb6c8b92b648a951aca24.tar.gz vaadin-framework-c9e8218799152dd90bacb6c8b92b648a951aca24.zip |
Applying patch: remak of variable handling in sass (partial for e.g #9492 and others)
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass/selector')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/selector/SelectorUtil.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/selector/SelectorUtil.java b/theme-compiler/src/com/vaadin/sass/selector/SelectorUtil.java index d93f37c175..788f297cac 100644 --- a/theme-compiler/src/com/vaadin/sass/selector/SelectorUtil.java +++ b/theme-compiler/src/com/vaadin/sass/selector/SelectorUtil.java @@ -29,6 +29,7 @@ import org.w3c.css.sac.SiblingSelector; import org.w3c.css.sac.SimpleSelector; import org.w3c.flute.parser.selectors.AndConditionImpl; import org.w3c.flute.parser.selectors.AttributeConditionImpl; +import org.w3c.flute.parser.selectors.ChildSelectorImpl; import org.w3c.flute.parser.selectors.ClassConditionImpl; import org.w3c.flute.parser.selectors.ConditionFactoryImpl; import org.w3c.flute.parser.selectors.DirectAdjacentSelectorImpl; @@ -305,4 +306,28 @@ public class SelectorUtil { return one == null ? another == null : toString(one).equals( toString(another)); } + + public static Selector createSelectorAndreplaceSelectorVariableWithValue( + Selector selector, String variable, String value) throws Exception { + + SelectorFactoryImpl factory = new SelectorFactoryImpl(); + + ElementSelector es = factory.createElementSelector( + null, + ((ElementSelector) selector).getLocalName().replaceAll( + variable, value)); + + if (selector instanceof ConditionalSelector) { + return factory.createConditionalSelector(es, + ((ConditionalSelector) selector).getCondition()); + } else if (selector instanceof DescendantSelector) { + return factory.createDescendantSelector(es, + ((DescendantSelector) selector).getSimpleSelector()); + } else if (selector instanceof ChildSelectorImpl) { + return factory.createChildSelector(es, + ((DescendantSelector) selector).getSimpleSelector()); + } else { + throw new Exception("Invalid selector type"); + } + } } |