-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: using special characters in attribute static strings
- Loading branch information
1 parent
4d309ee
commit c01c628
Showing
14 changed files
with
164 additions
and
114 deletions.
There are no files selected for viewing
This file contains 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 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,47 @@ | ||
import { TemplateElement, defineElement, html, Directive, defineDirective } from '../../index.js'; | ||
|
||
const directive = defineDirective(class extends Directive {}); | ||
|
||
class ChildNodesElement extends TemplateElement { | ||
properties() { | ||
return { | ||
text: 'Hello', | ||
count: 3, | ||
}; | ||
} | ||
|
||
template() { | ||
const list = []; | ||
for (let i = 0; i < this.count; i++) { | ||
list.push(i); | ||
} | ||
|
||
const p = document.createElement('p'); | ||
p.textContent = 'DOM Element'; | ||
|
||
const templateResult = html` | ||
<div>no interpolation</div> | ||
<div>${'single text interpolation'}</div> | ||
<div>${'multiple'} text ${'interpolations'}</div> | ||
<div>${html`template result interpolation with static text`}</div> | ||
<div>${html`<div>template result interpolation with html</div>`}</div> | ||
<ul> | ||
${list.map((item) => html`<li>${item}</li>`)} | ||
</ul> | ||
<div class="test"> | ||
${[ | ||
this.count, | ||
1, | ||
'Text', | ||
html`<span>Foo</span>`, | ||
html`<span>${this.count}</span>`, | ||
() => 'Function', | ||
p, | ||
]} | ||
</div> | ||
`; | ||
console.log('templateResult', templateResult.toString()); | ||
return templateResult; | ||
} | ||
} | ||
defineElement('attributes-element', ChildNodesElement); |
This file contains 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,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<script type="module" src="child-nodes-element.js"></script> | ||
</head> | ||
<body> | ||
<div class="container mx-auto p-8 border-4 rounded-lg m-8"> | ||
<attributes-element></attributes-element> | ||
</div> | ||
</body> | ||
</html> |
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.