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

fix: testing for instanceof TemplateResult #129

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 src/dom-parts/TemplateResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const getValue = (value) => {
case Array.isArray(value):
return value.map(getValue).join('');
case value instanceof TemplateResult:
// TODO: instanceof is not working when element-js is used in different modules...
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the todo here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not to use instanceof maybe?! We could go back to setting some $$__magic_varibales on the classes and check for those.
But there could be another problem. This happens when npm can't hoist element-js and the bundler uses two different versions. If we changed the instanceof check to something else - we could end up with different versions of element-js that are not compatible with each other?

return value.toString();
case value.strings !== undefined && value.values !== undefined:
// TODO: this is also a test for TemplateResult...
return value.toString();
case value.__unsafeHTML:
return value.string;
Expand Down
Loading