-
Notifications
You must be signed in to change notification settings - Fork 161
Partial façade for custom element support #697
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
@js.native | ||
sealed trait ShadowRootMode extends js.Any | ||
|
||
object ShadowRootMode { | ||
val open: ShadowRootMode = "open".asInstanceOf[ShadowRootMode] | ||
val closed: ShadowRootMode = "closed".asInstanceOf[ShadowRootMode] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.scalajs.dom | ||
|
||
opaque type ShadowRootMode <: String = String | ||
|
||
object ShadowRootMode { | ||
val open: ShadowRootMode = "open" | ||
val closed: ShadowRootMode = "closed" | ||
} |
21 changes: 21 additions & 0 deletions
21
dom/src/main/scala/org/scalajs/dom/CustomElementRegistry.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
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. | ||
*/ | ||
@js.native | ||
@JSGlobal | ||
abstract class CustomElementRegistry extends js.Object { | ||
|
||
/** Defines a new custom element. */ | ||
def define(name: String, constructor: js.Dynamic, options: ElementDefinitionOptions = js.native): Unit | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dom/src/main/scala/org/scalajs/dom/ElementDefinitionOptions.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** An ElementDefinitionOptions object represents additional options associated with CustomElementRegsitry.define. */ | ||
trait ElementDefinitionOptions extends js.Object { | ||
|
||
/** String specifying the name of a built-in element to extend. Used to create a customized built-in element. */ | ||
var `extends`: js.UndefOr[String] = js.undefined | ||
} |
21 changes: 21 additions & 0 deletions
21
dom/src/main/scala/org/scalajs/dom/HTMLTemplateElement.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** The HTMLTemplateElement interface enables access to the contents of an HTML <template> element. */ | ||
@js.native | ||
@JSGlobal | ||
abstract class HTMLTemplateElement extends HTMLElement { | ||
|
||
/** A read-only DocumentFragment which contains the DOM subtree representing the <template> element's template | ||
* contents. | ||
*/ | ||
def content: DocumentFragment = js.native | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API | ||
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later. | ||
* http://creativecommons.org/licenses/by-sa/2.5/ | ||
* | ||
* Everything else is under the MIT License http://opensource.org/licenses/MIT | ||
*/ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation._ | ||
|
||
/** The ShadowRoot interface of the Shadow DOM API is the root node of a DOM subtree that is rendered separately from a | ||
* document's main DOM tree. | ||
* | ||
* You can retrieve a reference to an element's shadow root using its Element.shadowRoot property, provided it was | ||
* created using Element.attachShadow() with the mode option set to open. | ||
*/ | ||
@js.native | ||
@JSGlobal | ||
abstract class ShadowRoot extends DocumentFragment { | ||
|
||
/** Returns the Element within the shadow tree that has focus. */ | ||
def activeElement: Element = js.native | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.scalajs.dom | ||
|
||
import scala.scalajs.js | ||
|
||
/** A ShadowRootInit object represents additional options associated with Element.attachShadow. */ | ||
trait ShadowRootInit extends js.Object { | ||
|
||
/** A string specifying the encapsulation mode for the shadow DOM tree. This can be one of: | ||
* | ||
* open: Elements of the shadow root are accessible from JavaScript outside the root, for example using | ||
* Element.shadowRoot: element.shadowRoot; // Returns a ShadowRoot obj | ||
* | ||
* closed: Denies access to the node(s) of a closed shadow root from JavaScript outside it: element.shadowRoot; // | ||
* Returns null | ||
*/ | ||
var mode: ShadowRootMode | ||
|
||
/** A boolean that, when set to true, specifies behavior that mitigates custom element issues around focusability. | ||
* When a non-focusable part of the shadow DOM is clicked, the first focusable part is given focus, and the shadow | ||
* host is given any available :focus styling. | ||
*/ | ||
var delegatesFocus: js.UndefOr[Boolean] = js.undefined | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.