-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Migrate to custom elements v1 API #4167
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b324374
Migrate a-node, a-entity, a-scene to custom elements v1
dmarcos 6086133
Primitives support
dmarcos 9f4f1f8
Migrate rest of the elements
dmarcos 3ba1ef3
Remove old wrappers and update polyfill
dmarcos 2679f7a
Fix tests
dmarcos de252fb
Address polyfill quirks
dmarcos a570232
Apply suggestions from code review
dmarcos 7fc0b29
Incorporate review feedback to handle self in class constructors
dmarcos 8931049
Address more review comments
dmarcos 1e0a25d
Stub HTMLElement and customElements for node tests
dmarcos 8e3e35b
Bump travis node version
dmarcos 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
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 |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ addons: | |
| - google-chrome-stable | ||
|
|
||
| node_js: | ||
| - '4.6' | ||
| - '7.5' | ||
|
|
||
| install: | ||
| - npm install | ||
|
|
||
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
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
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 |
|---|---|---|
| @@ -1,48 +1,43 @@ | ||
| /* global customElements, HTMLElement */ | ||
| var debug = require('../utils/debug'); | ||
| var registerElement = require('./a-register-element').registerElement; | ||
|
|
||
| var warn = debug('core:cubemap:warn'); | ||
|
|
||
| /** | ||
| * Cubemap element that handles validation and exposes list of URLs. | ||
| * Does not listen to updates. | ||
| */ | ||
| module.exports = registerElement('a-cubemap', { | ||
| prototype: Object.create(window.HTMLElement.prototype, { | ||
| /** | ||
| * Calculates this.srcs. | ||
| */ | ||
| attachedCallback: { | ||
| value: function () { | ||
| this.srcs = this.validate(); | ||
| }, | ||
| writable: window.debug | ||
| }, | ||
| class ACubeMap extends HTMLElement { | ||
| /** | ||
| * Calculates this.srcs. | ||
| */ | ||
| constructor (self) { | ||
dmarcos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self = super(self); | ||
| self.srcs = self.validate(); | ||
| return self; | ||
| } | ||
|
|
||
| /** | ||
| * Checks for exactly six elements with [src]. | ||
| * Does not check explicitly for <img>s in case user does not want | ||
| * prefetching. | ||
| * | ||
| * @returns {Array|null} - six URLs if valid, else null. | ||
| */ | ||
| validate: { | ||
| value: function () { | ||
| var elements = this.querySelectorAll('[src]'); | ||
| var i; | ||
| var srcs = []; | ||
| if (elements.length === 6) { | ||
| for (i = 0; i < elements.length; i++) { | ||
| srcs.push(elements[i].getAttribute('src')); | ||
| } | ||
| return srcs; | ||
| } | ||
| // Else if there are not six elements, throw a warning. | ||
| warn( | ||
| '<a-cubemap> did not contain exactly six elements each with a ' + | ||
| '`src` attribute.'); | ||
| }, | ||
| writable: window.debug | ||
| /** | ||
| * Checks for exactly six elements with [src]. | ||
| * Does not check explicitly for <img>s in case user does not want | ||
| * prefetching. | ||
| * | ||
| * @returns {Array|null} - six URLs if valid, else null. | ||
| */ | ||
| validate () { | ||
| var elements = this.querySelectorAll('[src]'); | ||
| var i; | ||
| var srcs = []; | ||
| if (elements.length === 6) { | ||
| for (i = 0; i < elements.length; i++) { | ||
| srcs.push(elements[i].getAttribute('src')); | ||
| } | ||
| return srcs; | ||
| } | ||
| }) | ||
| }); | ||
| // Else if there are not six elements, throw a warning. | ||
| warn( | ||
| '<a-cubemap> did not contain exactly six elements each with a ' + | ||
| '`src` attribute.'); | ||
| } | ||
| } | ||
|
|
||
| customElements.define('a-cubemap', ACubeMap); | ||
Oops, something went wrong.
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.