v0.1.2
Migration
Migration should be fairly smooth. Only a few breaking changes were made.
The attribute syntax was simplified
The old syntax for defining attributes was a bit clunky:
implicit class TagAttributesCustomType(tag: Tag[pine.tag.Div]) {
def myValue: Option[String] = tag.attr("my-value").map(_.toString)
def myValue(value: String): Tag[CustomType] = tag.setAttr("my-value", value)
}
myDiv.myValue // Returns Option[String]
This code now becomes:
implicit class TagAttributesCustomType(tag: Tag[pine.tag.Div]) {
val myValue = TagAttribute[CustomType, String](tag, "my-value")
}
myDiv.myValue() // Returns String
The syntax for TagRef
attributes was changed as well. See the manual for more details on defining attributes on Tag
and TagRef
.
Token list attributes have better support
// The HTML attribute "class" used to be stringly typed:
tag.Div.`class`("a")
// Now, it is equipped with functions for more convenient manipulation:
tag.Div.`class`.add("a")
This allows us to extend the functionality previously offered by css
to all other token list attributes:
// Deprecated:
tagRef.css(state, "css")
// Use instead:
tagRef.`class`.state(state, "css")
See this section in the manual for more details.
Improvements
TagRef
: Introducedopt
to allow for optional references (#43).
Depending on the TagRef
, dom
now returns the concrete type:
TagRef.ByTag[tag.A].dom: dom.html.Anchor
TagRef.ByTag[tag.A].opt.dom: Option[dom.html.Anchor]
TagRef.ByTag[tag.A].each.dom: List[dom.html.Anchor] // Before: domAll
- Boolean attributes can be defined for custom types (#36)
TagRef
: AddinsertAt()
(dfba494)TagRef
: AddinsertBefore()
andinsertAfter()
(3833652)TagRef
: AddclearAll()
(c376427)TagRef
: Add missing event handlers forcut
,paste
andcopy
(650e3cb, ea37bdb)TagRef
: Remove redundant event handlers from HTML tags (81cc3ef)Node
: Addtag()
to change the tag name (f79420f)Node
: AddbyTagAll()
andbyClassAll()
(7adb356)XmlParser
: Handle CDATA tags (c402b4a)
Bug fixes
- Fix attributes of Boolean types such as
readonly
(#44) - Support string concatenation in HTML/XML interpolator (#41)
- Fix all file descriptors when loading HTML files (5563657, b5d0a63)
- Do not report errors to the browser console when parsing valid HTML/XML documents (1ca1173)
Contributors
Thanks to @erikvanoosten for extensive testing and ideas.