Skip to content
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

Add upgrade() whenDefined() to CustomElementRegistry #831

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,10 @@ CryptoKey[JC] val usages: js.Array[KeyUsage]
CryptoKeyPair[JT] val privateKey: CryptoKey
CryptoKeyPair[JT] val publicKey: CryptoKey
CustomElementRegistry[JC] def define(name: String, constructor: js.Dynamic, options: ElementDefinitionOptions?): Unit
CustomElementRegistry[JC] def get(name: String): js.Dynamic
CustomElementRegistry[JC] def getName(constructor: js.Dynamic): String
CustomElementRegistry[JC] def upgrade(root: Node): Unit
CustomElementRegistry[JC] def whenDefined(name: String): js.Promise[Any]
CustomEvent[JC] def bubbles: Boolean
CustomEvent[JC] def cancelBubble: Boolean
CustomEvent[JC] def cancelable: Boolean
Expand Down
4 changes: 4 additions & 0 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,10 @@ CryptoKey[JC] val usages: js.Array[KeyUsage]
CryptoKeyPair[JT] val privateKey: CryptoKey
CryptoKeyPair[JT] val publicKey: CryptoKey
CustomElementRegistry[JC] def define(name: String, constructor: js.Dynamic, options: ElementDefinitionOptions?): Unit
CustomElementRegistry[JC] def get(name: String): js.Dynamic
CustomElementRegistry[JC] def getName(constructor: js.Dynamic): String
CustomElementRegistry[JC] def upgrade(root: Node): Unit
CustomElementRegistry[JC] def whenDefined(name: String): js.Promise[Any]
CustomEvent[JC] def bubbles: Boolean
CustomEvent[JC] def cancelBubble: Boolean
CustomEvent[JC] def cancelable: Boolean
Expand Down
18 changes: 18 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/CustomElementRegistry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ import scala.scalajs.js.annotation._

/** The CustomElementRegistry interface provides methods for registering custom elements and querying registered
* elements. To get an instance of it, use the window.customElements property.
* https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry

*/
@js.native
@JSGlobal
abstract class CustomElementRegistry extends js.Object {

/** Returns the constructor for a previously-defined custom element. */
def get(name: String): js.Dynamic
cyz1901 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def get(name: String): js.Dynamic
def get(name: String): js.UndefOr[js.Dynamic]


/** Returns the name for a previously-defined custom element.
* @param constructor
* Constructor for the custom element.
*/
def getName(constructor: js.Dynamic): String
cyz1901 marked this conversation as resolved.
Show resolved Hide resolved

/** Defines a new custom element. */
def define(name: String, constructor: js.Dynamic, options: ElementDefinitionOptions = js.native): Unit

/** Upgrades a custom element directly, even before it is connected to its shadow root. */
def upgrade(root: Node): Unit

/** Returns an empty Promise that resolves when a custom element becomes defined with the given name. If such a custom
* element is already defined, the returned promise is immediately fulfilled.
*/
def whenDefined(name: String): js.Promise[Any]
Copy link
Member

@armanbilge armanbilge Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please copy the doc from here.

Suggested change
def whenDefined(name: String): js.Promise[Any]
def whenDefined(name: String): js.Promise[js.Dynamic]

}
Loading