Skip to content

Commit 1a14eb3

Browse files
authoredSep 6, 2021
Merge pull request #561 from scala-js/issue/447
Add remove and other missing Element methods
2 parents c95ef2c + a423492 commit 1a14eb3

File tree

3 files changed

+1220
-0
lines changed

3 files changed

+1220
-0
lines changed
 

‎api-reports/2_12.txt

Lines changed: 595 additions & 0 deletions
Large diffs are not rendered by default.

‎api-reports/2_13.txt

Lines changed: 595 additions & 0 deletions
Large diffs are not rendered by default.

‎src/main/scala/org/scalajs/dom/lib.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,36 @@ trait NonDocumentTypeChildNode extends js.Object {
423423
@JSGlobal
424424
abstract class Element extends Node with NodeSelector with ParentNode with NonDocumentTypeChildNode {
425425

426+
/** Removes the element from the tree it belongs to. */
427+
def remove(): Unit = js.native
428+
429+
/** Inserts a set of Node or DOMString objects in the children list of this Element's parent, just before this
430+
* Element. DOMString objects are inserted as equivalent Text nodes.
431+
*/
432+
def before(nodes: (Node | String)*): Unit = js.native
433+
434+
/** Inserts a set of Node or DOMString objects in the children list of the Element's parent, just after the Element.
435+
* DOMString objects are inserted as equivalent Text nodes.
436+
*/
437+
def after(nodes: (Node | String)*): Unit = js.native
438+
439+
/** Inserts a set of Node objects or DOMString objects after the last child of the Element. DOMString objects are
440+
* inserted as equivalent Text nodes.
441+
*
442+
* Differences from Node.appendChild():
443+
*
444+
* - Element.append() allows you to also append DOMString objects, whereas Node.appendChild() only accepts Node
445+
* objects.
446+
* - Element.append() has no return value, whereas Node.appendChild() returns the appended Node object.
447+
* - Element.append() can append several nodes and strings, whereas Node.appendChild() can only append one node.
448+
*/
449+
def append(nodes: (Node | String)*): Unit = js.native
450+
451+
/** Inserts a set of Node objects or DOMString objects before the first child of the Element. DOMString objects are
452+
* inserted as equivalent Text nodes.
453+
*/
454+
def prepend(nodes: (Node | String)*): Unit = js.native
455+
426456
/** A DOMString representing the namespace prefix of the element, or null if no prefix is specified. */
427457
def prefix: String = js.native
428458

0 commit comments

Comments
 (0)
Please sign in to comment.