I've been treating "..." #> None and "..." #> "" as more or less
interchangeable, but it looks like this is not always true:
With 2.4-M3:
scala> ("#foo *" #> "")(<td id="foo"></td>)
res1: scala.xml.NodeSeq = NodeSeq(<td id="foo"></td>)
scala> ("#foo *" #> (None: Option[String]))(<td id="foo"></td>)
res2: scala.xml.NodeSeq = NodeSeq()
scala> ("#foo *" #> Nil)(<td id="foo"></td>)
res3: scala.xml.NodeSeq = NodeSeq(<td id="foo"></td>)
I would expect "#foo *" #> None to wipe out the <td>'s children, but
not remove the element itself. Does this make sense? If so, I'll
open a ticket for myself.
Pete
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
+1
I've encountered this oddity my self (2.4-M1) and agree that "#foo *" #>
None on a (<td id="foo"></td>) shouldn't wipe out the TD-element itself
but its children, in which this case is none, ie. leave the node-seq
un-altered.
--
Andreas Joseph Krogh <and...@officenet.no>
Senior Software Developer / CTO
Public key: http://home.officenet.no/~andreak/public_key.asc
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Rosenholmveien 25 | know how to do a thing and to watch |
1414 Troll�sen | somebody else doing it wrong, without |
NORWAY | comment. |
Org.nr: NO 981 479 076 | |
| |
Tlf: +47 24 15 38 90 | |
Fax: +47 24 15 38 91 | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
... snip ...
There are a few examples in the original thread:
http://groups.google.com/group/liftweb/browse_thread/thread/ee2ec1146a79a550/
But, immediately after committing it occurred to me that this is a
pretty big change. Andreas noted that he didn't expect ("#foo *" #>
None)(<td id="foo"></td>) to wipe out the <td>, but I've often relied
on ("#foo *" #> Nil)(<td id="foo"></td>) to do exactly that.
My suggestion would be to make the suggested change for None, but keep
the existing behavior for Nil. We have a lot of transforms basically
identical to Andreas's example and need a lot of ugly getOrElse("")
calls to work around the current behavior.
That said, see the example at end of
http://simply.liftweb.net/index-7.10.html#toc-Section-7.10.
In short, this is more than just a bug fix and I think the argument
could be made to leave well enough alone too.
... snip ...
The proposed behavior makes more sense to me though.
Pete
I think the * means "don't affect the parent, only transform the children."Personally I think the principle of least surprise is more important than not breaking code that relies on a bug.
> I think the * means "don't affect the parent, only transform the children."
> Personally I think the principle of least surprise is more important than
> not breaking code that relies on a bug.
Agreed
/Jeppe