diff --git a/core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala b/core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala old mode 100644 new mode 100755 index e6c1bd8e2c..633b2ed485 --- a/core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala +++ b/core/util/src/test/scala/net/liftweb/util/CssSelectorSpec.scala @@ -503,7 +503,26 @@ object CssBindHelpersSpec extends Specification with XmlMatchers { (res \ "@class").length must_== 0 } + "don't merge class attribute" in { + val func = "p !!" #> 10 + val res = func.apply(
Test
) + (res \ "@class").text must_== "replacement" + } + + "merge other attributes when using don't merge class modification" in { + val func = "p !!" #> 10 + val res = func.apply(Test
) + (res \ "@data-one").text must_== "1" + (res \ "@data-two").text must_== "2" + (res \ "@class").text must_== "replacement" + } + "leave node class attribute for replacement without class" in { + // TODO: Since was agreed not to change current behaviour, create test for it (https://groups.google.com/forum/#!topic/liftweb/Nswcxoykspc) + val func = "p !!" #> 10 + val res = func.apply(Test
) + (res \ "@class").text must_== "first second" + } "Remove a subnode's class attribute" in { diff --git a/docs/css-selectors.adoc b/docs/css-selectors.adoc old mode 100644 new mode 100755 index 01b7bcf9d8..2f9bb17626 --- a/docs/css-selectors.adoc +++ b/docs/css-selectors.adoc @@ -266,14 +266,15 @@ Remove from attribute rule: `[attribute-name!]`:: its own separated by a space. For example, `^ [class!]` will remove the class named by the transformation result from all root elements. -Don't merge attributes rule: `!!`:: +Don't merge class attribute rule: `!!`:: By default, if the transformation yields a single element and the element matched by the selector is being replaced by that result, the attributes from the matched element are merged into the attributes of the transformation's - element. This modifier prevents that from happening. For example, by default - doing `"input" #> ` and applying it to `` would - yield ``. Doing `"input !!" #> ` would instead yield - ``. + element. This modifier prevents *ONLY* class attribute merging from happening. + For example, by default doing `"input" #> ` and applying it to + `` would yield ``. + Doing `"input !!" #> ` would instead yield + ``. Lift node rule: `^^`:: This rule will lift the first selected element all the way to the root of the