Skip to content

Commit

Permalink
Merge pull request #73 from sparsetech/bug/ol-start
Browse files Browse the repository at this point in the history
Attributes: Fix type of 'start' attribute on <ol>
  • Loading branch information
tindzk authored Oct 4, 2020
2 parents 7a0d566 + a6a3df8 commit 35b0133
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion project/MDNParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ object MDNParser {
"required", "reversed", "scoped", "seamless", "selected", "sortable",
"spellcheck", "translate", "truespeed", "typemustmatch", "visible")

/** Override type of these attributes */
val IntegerAttributes = Set("start")

/** @see https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList */
val TokenSetAttributes = Set("class", "rel", "sandbox")

Expand Down Expand Up @@ -255,6 +258,7 @@ object MDNParser {
val tpe =
if (BooleanAttributes.contains(name)) "Boolean"
else if (TokenSetAttributes.contains(name)) "TokenSet"
else if (IntegerAttributes.contains(name)) "Int"
else "String"

Some(Attribute(name, deprecated || deleted || obsolete, docs, tpe))
Expand Down Expand Up @@ -394,4 +398,4 @@ object MDNParser {

Seq(attrsFile, attrsTagRefFile)
}
}
}
4 changes: 2 additions & 2 deletions src/main/scala/pine/tag/Attributes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -873,14 +873,14 @@ trait Attributes {
implicit class TagAttributesOl(tag: Tag[pine.tag.Ol]) {
val compact = TagAttribute[pine.tag.Ol, Boolean](tag, "compact")
val reversed = TagAttribute[pine.tag.Ol, Boolean](tag, "reversed")
val start = TagAttribute[pine.tag.Ol, String](tag, "start")
val start = TagAttribute[pine.tag.Ol, Int](tag, "start")
val `type` = TagAttribute[pine.tag.Ol, String](tag, "type")
}

implicit class TagRefAttributesOl(tagRef: TagRef[tag.Ol]) {
val compact = TagRefAttribute[tag.Ol, Boolean](tagRef, "compact")
val reversed = TagRefAttribute[tag.Ol, Boolean](tagRef, "reversed")
val start = TagRefAttribute[tag.Ol, String](tagRef, "start")
val start = TagRefAttribute[tag.Ol, Int](tagRef, "start")
val `type` = TagRefAttribute[tag.Ol, String](tagRef, "type")
}

Expand Down
5 changes: 5 additions & 0 deletions src/test/scala/pine/NodeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,9 @@ class NodeSpec extends FunSuite {
assert(tag.Div.dataLanguage(Language.Spanish).toHtml ==
"""<div data-language="spanish"></div>""")
}

test("Ordered list with custom start index") {
val ol = tag.Ol.start(42)
assert(ol.toHtml == "<ol start=\"42\"></ol>")
}
}

0 comments on commit 35b0133

Please sign in to comment.