Skip to content

Add upgrade() whenDefined() to CustomElementRegistry #831

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Prev Previous commit
format
  • Loading branch information
cyz1901 committed Mar 6, 2024
commit b333d618c820a73656a3bd9c81e9e358ffebefe8
16 changes: 10 additions & 6 deletions dom/src/main/scala/org/scalajs/dom/CustomElementRegistry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ import scala.scalajs.js.annotation._
@JSGlobal
abstract class CustomElementRegistry extends js.Object {

/** Returns the constructor for a previously-defined custom element. */
/** Returns the constructor for a previously-defined custom element. */
def get(name: String): js.Dynamic
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
/** Returns the name for a previously-defined custom element.
* @param constructor
* Constructor for the custom element.
*/
def getName(constructor: js.Dynamic): String

/** 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]

}