Skip to content

Commit

Permalink
Merge pull request #202 from ThoughtWorksInc/Atry-patch-1
Browse files Browse the repository at this point in the history
Reverse attributes
  • Loading branch information
Atry committed Aug 10, 2019
2 parents b752e62 + 4e7a091 commit 011e9dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ trait XmlExtractor {
)
}
""") =>
(QName(prefixOption, localPart), attributes.map {
(QName(prefixOption, localPart), attributes.view.reverse.map {
case q"""$$md = new _root_.scala.xml.UnprefixedAttribute(${Literal(Constant(key: String))}, $value, $$md)""" =>
UnprefixedName(key) -> value
case q"""$$md = new _root_.scala.xml.PrefixedAttribute(${Literal(Constant(pre: String))}, ${Literal(
Constant(key: String))}, $value, $$md)""" =>
PrefixedName(pre, key) -> value
}, minimizeEmpty, nodeBufferStar(child))
}.toList, minimizeEmpty, nodeBufferStar(child))
case Block(Nil,
Block(
Nil,
Expand Down
10 changes: 5 additions & 5 deletions dom/src/test/scala/com/thoughtworks/binding/domTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ final class domTest extends FreeSpec with Matchers {
<table title="My Tooltip" className="my-table"><thead><tr><td>First Name</td><td>Second Name</td><td>Age</td></tr></thead>{tbodyBinding.bind}</table>
}
tableBinding.watch()
assert(tableBinding.get.outerHTML == """<table class="my-table" title="My Tooltip"><thead><tr><td>First Name</td><td>Second Name</td><td>Age</td></tr></thead><tbody><tr><td>Steve</td><td>Jobs</td><td>10</td></tr><tr><td>Tim</td><td>Cook</td><td>12</td></tr><tr><td>Jeff</td><td>Lauren</td><td>13</td></tr></tbody></table>""")
assert(tableBinding.get.outerHTML == """<table title="My Tooltip" class="my-table"><thead><tr><td>First Name</td><td>Second Name</td><td>Age</td></tr></thead><tbody><tr><td>Steve</td><td>Jobs</td><td>10</td></tr><tr><td>Tim</td><td>Cook</td><td>12</td></tr><tr><td>Jeff</td><td>Lauren</td><td>13</td></tr></tbody></table>""")
filterPattern.value = "o"
assert(tableBinding.get.outerHTML == """<table class="my-table" title="My Tooltip"><thead><tr><td>First Name</td><td>Second Name</td><td>Age</td></tr></thead><tbody><tr><td>Steve</td><td>Jobs</td><td>10</td></tr><tr><td>Tim</td><td>Cook</td><td>12</td></tr></tbody></table>""")
assert(tableBinding.get.outerHTML == """<table title="My Tooltip" class="my-table"><thead><tr><td>First Name</td><td>Second Name</td><td>Age</td></tr></thead><tbody><tr><td>Steve</td><td>Jobs</td><td>10</td></tr><tr><td>Tim</td><td>Cook</td><td>12</td></tr></tbody></table>""")
}

"NodeSeq" in {
Expand Down Expand Up @@ -199,7 +199,7 @@ final class domTest extends FreeSpec with Matchers {
val div = document.createElement("div")
dom.render(div, input)
val outerHTML = div.outerHTML
assert(outerHTML == """<div><br class="BR" id="myBr"/></div>""")
assert(outerHTML == """<div><br id="myBr" class="BR"/></div>""")
}

"StyleVisibility" in {
Expand Down Expand Up @@ -400,7 +400,7 @@ final class domTest extends FreeSpec with Matchers {
val div = document.createElement("div")
dom.render(div, input)
val outerHTML = div.outerHTML
assert(outerHTML == """<div><br class="BR" id="html-id"/></div>""")
assert(outerHTML == """<div><br id="html-id" class="BR"/></div>""")
}

"local-id in BindingSeq" in {
Expand Down Expand Up @@ -444,7 +444,7 @@ final class domTest extends FreeSpec with Matchers {
val div = document.createElement("div")
dom.render(div, tag)

assert(div.outerHTML == """<div><custom-tag custom-key="value" id="custom"><data id="123">CUSTOM-TAG</data></custom-tag></div>""")
assert(div.outerHTML == """<div><custom-tag id="custom" custom-key="value"><data id="123">CUSTOM-TAG</data></custom-tag></div>""")
}

}
Expand Down

0 comments on commit 011e9dd

Please sign in to comment.