The project in this repo demonstrates a potential bug in the CSS Selector Binding feature of Lift 2.2.
Starting with the lift_basic template provided in the Lift 2.2 sbt Zip, a collectThemAll
method was added to the HelloWorld snippet. According to the Binding to children section of the Binding via CSS Selectors Assembla page, this method should make three copies of the element with an id="token"
attribute and replace the content of each element with the strings in the List("foo", "bar", "baz")
.
If you start up the application with ./sbt jetty
and direct your browser to localhost:8080, you will see three links in the menu, div, span, and ul. Each page invokes the collectThemAll
method in the HelloWorld snippet and binds it to the same element:
<li id="token">Uh-oh!</li>
The only difference between the pages is the parent tag of the <li>
tag. When the parent tag is a <div>
or a <ul>
, the page renders correctly, as a unordered list:
- foo
- bar
- baz
When the parent is a <span>
tag, however, the binding fails and renders this:
- Uh-oh!
Obviously, a <li>
tag inside a <span>
is not proper HTML, but it’s surprising that the binding fails silently in this way.