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

bug/issue 144 check CE registry before assuming a custom element definition exists #146

Merged
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
11 changes: 8 additions & 3 deletions src/dom-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// https://developer.mozilla.org/en-US/docs/Web/API/Node
// EventTarget <- Node
// TODO should be an interface?

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO should be an interface?'

Check warning on line 12 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO should be an interface?'
class Node extends EventTarget {
// eslint-disable-next-line
cloneNode(deep) {
Expand Down Expand Up @@ -104,7 +104,7 @@
this.content = new DocumentFragment();
}

// TODO open vs closed shadow root

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO open vs closed shadow root'

Check warning on line 107 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO open vs closed shadow root'
set innerHTML(html) {
if (this.content) {
this.content.innerHTML = `
Expand All @@ -123,15 +123,20 @@
// https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
class CustomElementsRegistry {
constructor() {
this.customElementsRegistry = {};
// TODO this should probably be a set or otherwise follow the spec?

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably be a set or...'

Check warning on line 126 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably be a set or...'
// https://github.com/ProjectEvergreen/wcc/discussions/145
this.customElementsRegistry = new Map();
}

define(tagName, BaseClass) {
this.customElementsRegistry[tagName] = BaseClass;
// TODO this should probably fail as per the spec...

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this should probably fail as per...'

Check warning on line 132 in src/dom-shim.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this should probably fail as per...'
// e.g. if(this.customElementsRegistry.get(tagName))
// https://github.com/ProjectEvergreen/wcc/discussions/145
this.customElementsRegistry.set(tagName, BaseClass);
}

get(tagName) {
return this.customElementsRegistry[tagName];
return this.customElementsRegistry.get(tagName);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/wcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti

// https://github.com/ProjectEvergreen/wcc/pull/67/files#r902061804
const { pathname } = elementURL;
const element = tagName
? customElements.get(tagName)
: (await import(pathname)).default;
const element = customElements.get(tagName) ?? (await import(pathname)).default;
const dataLoader = (await import(pathname)).getData;
const data = props
? props
Expand Down
Loading