File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
core/util/src/test/scala/net/liftweb/util Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,26 @@ object CssBindHelpersSpec extends Specification with XmlMatchers {
503503 (res \ " @class" ).length must_== 0
504504 }
505505
506+ " don't merge class attribute" in {
507+ val func = " p !!" #> <span class =" replacement" >10 </span >
508+ val res = func.apply(<p class =" first second" >Test </p >)
509+ (res \ " @class" ).text must_== " replacement"
510+ }
511+
512+ " merge other attributes when using don't merge class modification" in {
513+ val func = " p !!" #> <span data-two =" 2" class =" replacement" >10 </span >
514+ val res = func.apply(<p data-one =" 1" class =" first second" >Test </p >)
515+ (res \ " @data-one" ).text must_== " 1"
516+ (res \ " @data-two" ).text must_== " 2"
517+ (res \ " @class" ).text must_== " replacement"
518+ }
506519
520+ " leave node class attribute for replacement without class" in {
521+ // TODO: Since was agreed not to change current behaviour, create test for it (https://groups.google.com/forum/#!topic/liftweb/Nswcxoykspc)
522+ val func = " p !!" #> <span >10 </span >
523+ val res = func.apply(<p class =" first second" >Test </p >)
524+ (res \ " @class" ).text must_== " first second"
525+ }
507526
508527 " Remove a subnode's class attribute" in {
509528
Original file line number Diff line number Diff line change @@ -266,14 +266,15 @@ Remove from attribute rule: `[attribute-name!]`::
266266 its own separated by a space. For example, `^ [class!]` will remove the
267267 class named by the transformation result from all root elements.
268268
269- Don't merge attributes rule: `!!`::
269+ Don't merge class attribute rule: `!!`::
270270 By default, if the transformation yields a single element and the element
271271 matched by the selector is being replaced by that result, the attributes from
272272 the matched element are merged into the attributes of the transformation's
273- element. This modifier prevents that from happening. For example, by default
274- doing `"input" #> <div />` and applying it to `<input type="text">` would
275- yield `<div type="text" />`. Doing `"input !!" #> <div />` would instead yield
276- `<div />`.
273+ element. This modifier prevents *ONLY* class attribute merging from happening.
274+ For example, by default doing `"input" #> <div class="c1"/>` and applying it to
275+ `<input class="c2" type="text"/>` would yield `<div type="text" class="c1 c2"/>`.
276+ Doing `"input !!" #> <div class="c1" />` would instead yield
277+ `<div type="text" class="c1"/>`.
277278
278279Lift node rule: `^^`::
279280 This rule will lift the first selected element all the way to the root of the
You can’t perform that action at this time.
0 commit comments