These are chat archives for ThoughtWorksInc/Binding.scala

26th
Aug 2016
William Ho
@williamho
Aug 26 2016 03:17
Is there a way to use a tag that doesn't exist in scalatags? (kind of like how data: can be used for attributes) Basically I want to create a <dialog> element but there's no such tag.
杨博 (Yang Bo)
@Atry
Aug 26 2016 03:27
Try document.createElement
William Ho
@williamho
Aug 26 2016 03:29
yeah that's what I ended up doing. was just wondering if there was a way to do it with HTML literal, but I guess not
杨博 (Yang Bo)
@Atry
Aug 26 2016 04:06
Not yet. I hope we could add custom xmlns support in the future
Chris Camel
@ccamel
Aug 26 2016 09:13
@Atry Yes. It would be a nice feature. I have the same problem with "svg" element.
杨博 (Yang Bo)
@Atry
Aug 26 2016 09:35
@chris-tek @williamho Here is a workaround: since currently all tags are rendered as com.thoughtworks.binding.dom.Runtime.TagsAndTags2.$labelName().render https://github.com/ThoughtWorksInc/Binding.scala/blob/9.0.x/dom/src/main/scala/com/thoughtworks/binding/dom.scala#L317 , you can provide an implicit view to TagsAndTags2.type.
implicit final class MyTags(_: TagsAndTags2.type) {
  final case class dialog() {
    def render = {
      document.createElement("dialog")
    }
  }
}
Chris Camel
@ccamel
Aug 26 2016 12:23

@Atry Yes, it works ! :+1:
I have still an issue, with custom attributes. Is there a way to express this kind of element:

<use xlink:href="#stroked-cancel"></use>

Note the namespace xlink. The following code does not work:

<use data:xlink:href="#stroked-cancel"></use>
杨博 (Yang Bo)
@Atry
Aug 26 2016 12:26
I guess you have to create a xlink property in your class for user element
in the the class that your render methed returns
William Ho
@williamho
Aug 26 2016 13:49
cool, I'll try the implicit class later. thanks!
Chris Camel
@ccamel
Aug 26 2016 16:07
@Atry I'm not sure I understand. You propose to do something like this:
    final case class use() {
      def render = {
        val element = document.createElement("use")
        element.setAttribute("xlink:href", "#stroked-cancel")
      }
    }
In the implicit view ?
But I have to do this for all use element. Can I use a case class with parameters ?