Skip to content

Commit

Permalink
Docs: Fix MDN urls for attr fragments, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
raquo committed Dec 4, 2023
1 parent a097b3c commit 3b8a485
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion js/src/test/scala/com/thirdparty/CompileSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CompileSpec extends AnyFunSpec with Matchers {
assert(html.display.domName == "display")

// Make sure there's no name conflict with htmlRootTag
html.htmlTag: Function2[String, Boolean, HtmlTag[dom.HTMLHtmlElement]]
val root = (html.htmlTag: Function2[String, Boolean, HtmlTag[dom.HTMLHtmlElement]])

// Event props

Expand Down
25 changes: 12 additions & 13 deletions js/src/test/scala/com/thirdparty/defs/attrs/HtmlAttrs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ trait HtmlAttrs {
* Declares the character encoding of the page or script. Used on meta and
* script elements.
*
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-charset object#attr-charset @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#charset meta#charset @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#charset script#charset @ MDN]]
*/
lazy val charset: HtmlAttr[String] = stringHtmlAttr("charset")

Expand Down Expand Up @@ -77,7 +78,7 @@ trait HtmlAttrs {
* The `height` attribute specifies the pixel height of the following elements:
* `<canvas>, <embed>, <iframe>, <img>, <input type="image">, <object>, <video>`
*
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-height object#attr-height @ MDN]]
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#height object#height @ MDN]]
*/
lazy val heightAttr: HtmlAttr[Int] = intHtmlAttr("height")

Expand All @@ -91,7 +92,7 @@ trait HtmlAttrs {
* supported by the browser. For example, file, ftp, and mailto work in most
* user agents.
*
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href a#attr-href @ MDN]]
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href a#href @ MDN]]
*/
lazy val href: HtmlAttr[String] = stringHtmlAttr("href")

Expand Down Expand Up @@ -128,9 +129,9 @@ trait HtmlAttrs {
* Specifies the URL of an image for `<img>` tag, for `type="image"` input buttons,
* or the URL of some other network resources like `<iframe>`.
*
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-src img#attr-src @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#src img#src @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#src input#src @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-src iframe#attr-src @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#src iframe#src @ MDN]]
*/
lazy val src: HtmlAttr[String] = stringHtmlAttr("src")

Expand All @@ -150,16 +151,14 @@ trait HtmlAttrs {


/**
* This attribute is used to define the type of the content linked to. The
* value of the attribute should be a MIME type such as text/html, text/css,
* and so on. The common use of this attribute is to define the type of style
* sheet linked and the most common current value is text/css, which indicates
* a Cascading Style Sheet format. You can use tpe as an alias for this
* attribute so you don't have to backtick-escape this attribute.
* This attribute has several meanings depending on what element it's applied to.
* It could indicate the type of a button, an input, a script, a stylesheet, etc.
*
* Aliases: [[typ]], [[tpe]]
*
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-type object#attr-type @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types input#input_types @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type button#type @ MDN]]
* - [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#type object#type @ MDN]]
*/
lazy val `type`: HtmlAttr[String] = stringHtmlAttr("type")

Expand All @@ -178,7 +177,7 @@ trait HtmlAttrs {
* The `width` attribute specifies the pixel width of the following elements:
* `<canvas>, <embed>, <iframe>, <img>, <input type="image">, <object>, <video>`
*
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-width object#attr-width @ MDN]]
* [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#width object#width @ MDN]]
*/
lazy val widthAttr: HtmlAttr[Int] = intHtmlAttr("width")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ object HtmlAttrDefs {
"script elements.",
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-charset",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#charset",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#charset",
),
),

Expand Down Expand Up @@ -92,6 +93,9 @@ object HtmlAttrDefs {
),
),

// This is NOT a true reflected attribute - the `form` property contains a reference
// the form element itself (an instance of dom.html.Form), whereas the form attribute
// contains the ID attribute of that element.
AttrDef(
tagType = HtmlTagType,
scalaName = "formId",
Expand All @@ -117,7 +121,7 @@ object HtmlAttrDefs {
"`<canvas>, <embed>, <iframe>, <img>, <input type=\"image\">, <object>, <video>`",
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-height",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#height",
),
),

Expand All @@ -141,7 +145,7 @@ object HtmlAttrDefs {
"user agents.",
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href",
),
),

Expand Down Expand Up @@ -209,9 +213,9 @@ object HtmlAttrDefs {
"or the URL of some other network resources like `<iframe>`.",
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-src",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#src",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#src",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-src",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#src",
),
),

Expand Down Expand Up @@ -245,15 +249,13 @@ object HtmlAttrDefs {
scalaValueType = "String",
codec = "StringAsIs",
commentLines = List(
"This attribute is used to define the type of the content linked to. The",
"value of the attribute should be a MIME type such as text/html, text/css,",
"and so on. The common use of this attribute is to define the type of style",
"sheet linked and the most common current value is text/css, which indicates",
"a Cascading Style Sheet format. You can use tpe as an alias for this",
"attribute so you don't have to backtick-escape this attribute.",
"This attribute has several meanings depending on what element it's applied to. ",
"It could indicate the type of a button, an input, a script, a stylesheet, etc."
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-type",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#type",
),
),

Expand Down Expand Up @@ -282,7 +284,7 @@ object HtmlAttrDefs {
"`<canvas>, <embed>, <iframe>, <img>, <input type=\"image\">, <object>, <video>`",
),
docUrls = List(
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attr-width",
"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#width",
),
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ object SvgAttrDefs {
),
),

// This is NOT a true reflected attribute - the `href` property contains the
// absolute URL (`href` attribute value resolved relative to current page URL)
AttrDef(
tagType = SvgTagType,
scalaName = "href",
Expand Down

0 comments on commit 3b8a485

Please sign in to comment.