Releases: sparsetech/pine
v0.1.7
Version 0.1.7 fixes a number of bugs and improves the parsing performance. A benchmark suite was added and is now triggered as part of every CI build. This release also adds support for Scala.js 1.2.0 and Scala Native 0.4.0-M2.
Migration
Previously, the DOM parser was used in Scala.js which had slightly different semantics depending on the browser. From this release onwards, the internal HTML parser is the default on all platforms.
If you were calling the internal HTML parser, the following changes are necessary:
pine.internal.HtmlParser.fromString(str, xml = false)
→pine.HtmlParser.fromString(str)
pine.internal.HtmlParser.fromString(str, xml = true)
→pine.XmlParser.fromString(str)
Bug fixes
- HtmlParser: Prevent infinite loop when tag is not closed (#61)
- HtmlParser: Parse DOCTYPE case-insensitively (#62)
- Travis CI: Use OpenJDK to fix CI build (#63)
- Fix
Node.removeAll()
(#66, by @mosteli) - Allow spaces before and after equal sign in attribute definition (#70, by @lavrov)
- Attributes: Fix type of
start
attribute on<ol>
(#73)
Improvements
v0.1.6
v0.1.5
v0.1.4
v0.1.3
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.