Skip to content

Add options parameter to Document#createElement #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1724,8 +1724,8 @@ Document[JC] def createAttributeNS(namespaceURI: String, qualifiedName: String):
Document[JC] def createCDATASection(data: String): CDATASection
Document[JC] def createComment(data: String): Comment
Document[JC] def createDocumentFragment(): DocumentFragment
Document[JC] def createElement(tagName: String): Element
Document[JC] def createElementNS(namespaceURI: String, qualifiedName: String): Element
Document[JC] def createElement(tagName: String, options: String | ElementCreationOptions?): Element
Document[JC] def createElementNS(namespaceURI: String, qualifiedName: String, options: String | ElementCreationOptions?): Element
Document[JC] def createEvent(eventInterface: String): Event
Document[JC] def createNSResolver(node: Node): XPathNSResolver
Document[JC] def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): NodeIterator
Expand Down Expand Up @@ -2065,6 +2065,7 @@ Element[JC] def setAttributeNodeNS(newAttr: Attr): Attr
Element[JC] def shadowRoot: ShadowRoot
Element[JC] def tagName: String
Element[JC] var textContent: String
ElementCreationOptions[JT] var is: js.UndefOr[String]
ElementDefinitionOptions[JT] var `extends`: js.UndefOr[String]
EndOfStreamError[JT]
EndOfStreamError[SO] val decode: EndOfStreamError
Expand Down Expand Up @@ -4901,8 +4902,8 @@ HTMLDocument[JC] def createAttributeNS(namespaceURI: String, qualifiedName: Stri
HTMLDocument[JC] def createCDATASection(data: String): CDATASection
HTMLDocument[JC] def createComment(data: String): Comment
HTMLDocument[JC] def createDocumentFragment(): DocumentFragment
HTMLDocument[JC] def createElement(tagName: String): Element
HTMLDocument[JC] def createElementNS(namespaceURI: String, qualifiedName: String): Element
HTMLDocument[JC] def createElement(tagName: String, options: String | ElementCreationOptions?): Element
HTMLDocument[JC] def createElementNS(namespaceURI: String, qualifiedName: String, options: String | ElementCreationOptions?): Element
HTMLDocument[JC] def createEvent(eventInterface: String): Event
HTMLDocument[JC] def createNSResolver(node: Node): XPathNSResolver
HTMLDocument[JC] def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): NodeIterator
Expand Down
9 changes: 5 additions & 4 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1724,8 +1724,8 @@ Document[JC] def createAttributeNS(namespaceURI: String, qualifiedName: String):
Document[JC] def createCDATASection(data: String): CDATASection
Document[JC] def createComment(data: String): Comment
Document[JC] def createDocumentFragment(): DocumentFragment
Document[JC] def createElement(tagName: String): Element
Document[JC] def createElementNS(namespaceURI: String, qualifiedName: String): Element
Document[JC] def createElement(tagName: String, options: String | ElementCreationOptions?): Element
Document[JC] def createElementNS(namespaceURI: String, qualifiedName: String, options: String | ElementCreationOptions?): Element
Document[JC] def createEvent(eventInterface: String): Event
Document[JC] def createNSResolver(node: Node): XPathNSResolver
Document[JC] def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): NodeIterator
Expand Down Expand Up @@ -2065,6 +2065,7 @@ Element[JC] def setAttributeNodeNS(newAttr: Attr): Attr
Element[JC] def shadowRoot: ShadowRoot
Element[JC] def tagName: String
Element[JC] var textContent: String
ElementCreationOptions[JT] var is: js.UndefOr[String]
ElementDefinitionOptions[JT] var `extends`: js.UndefOr[String]
EndOfStreamError[JT]
EndOfStreamError[SO] val decode: EndOfStreamError
Expand Down Expand Up @@ -4901,8 +4902,8 @@ HTMLDocument[JC] def createAttributeNS(namespaceURI: String, qualifiedName: Stri
HTMLDocument[JC] def createCDATASection(data: String): CDATASection
HTMLDocument[JC] def createComment(data: String): Comment
HTMLDocument[JC] def createDocumentFragment(): DocumentFragment
HTMLDocument[JC] def createElement(tagName: String): Element
HTMLDocument[JC] def createElementNS(namespaceURI: String, qualifiedName: String): Element
HTMLDocument[JC] def createElement(tagName: String, options: String | ElementCreationOptions?): Element
HTMLDocument[JC] def createElementNS(namespaceURI: String, qualifiedName: String, options: String | ElementCreationOptions?): Element
HTMLDocument[JC] def createEvent(eventInterface: String): Event
HTMLDocument[JC] def createNSResolver(node: Node): XPathNSResolver
HTMLDocument[JC] def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, entityReferenceExpansion: Boolean): NodeIterator
Expand Down
6 changes: 4 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/Document.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.|

/** Each web page loaded in the browser has its own document object. The Document interface serves as an entry point to
* the web page's content (the DOM tree, including elements such as <body> and <table>) and provides
Expand Down Expand Up @@ -124,10 +125,11 @@ abstract class Document extends Node with NodeSelector with DocumentEvent with P
/** In an HTML document creates the specified HTML element or HTMLUnknownElement if the element is not known. In a XUL
* document creates the specified XUL element. In other documents creates an element with a null namespaceURI.
*/
def createElement(tagName: String): Element = js.native
def createElement(tagName: String, options: String | ElementCreationOptions = js.native): Element = js.native

/** Creates an element with the specified namespace URI and qualified name. */
def createElementNS(namespaceURI: String, qualifiedName: String): Element = js.native
def createElementNS(namespaceURI: String, qualifiedName: String,
options: String | ElementCreationOptions = js.native): Element = js.native

/** createAttribute creates a new attribute node, and returns it. */
def createAttribute(name: String): Attr = js.native
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scalajs.dom

import scala.scalajs.js

trait ElementCreationOptions extends js.Object {
var is: js.UndefOr[String] = js.undefined
}