Dusty Greif
8a0302f9f3
Use `chromium` package to run karma tests
2022-01-26 14:18:11 +00:00
Dusty Greif
699741d90a
Merge pull request #15 from github/esm-import-extensions
2022-01-26 06:55:07 -07:00
Dusty Greif
f7ce7ddb4e
Add file extensions for imports
2022-01-26 04:16:34 +00:00
Dusty Greif
73a4610702
Require file extensions for imports
2022-01-26 04:16:25 +00:00
Keith Cirkel
238cb02ded
0.4.0
2021-03-09 12:22:33 +00:00
Keith Cirkel
eef927f3b7
Merge pull request #13 from github/feat-add-unsafe-html
...
feat: add unsafe-html directive
2021-03-09 12:17:18 +00:00
Keith Cirkel
0370a6735f
test(unsafe-html): test for attributepart use case
2021-03-09 11:53:17 +00:00
Keith Cirkel
2399273404
feat: add unsafe-html directive
2021-03-09 11:45:31 +00:00
Keith Cirkel
8c50314ff2
Merge pull request #12 from ItsJimi/fix-readme-typo
2021-03-05 22:30:19 +00:00
Jimi M
368107290e
docs: fix a typo in README
2021-03-05 22:42:34 +01:00
Kristján Oddsson
e27b8cbaed
Merge pull request #11 from github/change-package-metadata
...
Change package metadata
2021-03-04 13:49:54 +00:00
Kristján Oddsson
a3e569cd6e
change package metadata
2021-03-04 12:32:42 +00:00
Keith Cirkel
c31ef8d913
0.3.4
2021-03-01 15:50:51 +00:00
Keith Cirkel
e6b08c85e4
Merge pull request #10 from github/fix-until-allow-non-promise-values-in-type
...
fix(until): allow non Promise values in type
2021-03-01 15:05:12 +00:00
Keith Cirkel
38b6c0c964
fix: remove experimenting code
2021-03-01 14:56:17 +00:00
Keith Cirkel
ef5556488a
style: eslint --fix .
2021-03-01 14:55:37 +00:00
Keith Cirkel
f90737e488
fix(until): allow non Promise values in type
2021-02-26 15:17:10 +00:00
Keith Cirkel
4d42680e76
0.3.3
2021-01-25 18:16:16 +00:00
Keith Cirkel
1f15957162
Merge pull request #9 from github/fix-html-only-call-update-after-initial-render
...
fix(html): only call `update()` after initial render
2021-01-25 18:15:35 +00:00
Keith Cirkel
72836e7121
fix(html): only call `update()` after initial render
...
Calling update on the create step meant this was initializing some
DocumentFragments twice, which causes them to empty out their contents,
therefore elements were not getting rendered correctly. Aside from that,
it's unnecessary work to call update with exactly the same contents!
2021-01-25 18:01:49 +00:00
Keith Cirkel
7a15332982
0.3.2
2021-01-19 18:32:28 +00:00
Keith Cirkel
cd39dcbd76
0.3.1
2021-01-19 17:24:57 +00:00
Keith Cirkel
3c6bdc4485
Merge pull request #8 from github/fix-html-allow-for-nested-text-nodes-in-iterables
...
Fix html allow for nested text nodes in iterables
2021-01-19 17:19:35 +00:00
Keith Cirkel
f638aa50d3
0.3.0
2021-01-19 17:10:26 +00:00
Keith Cirkel
1f7f3be6c0
Merge pull request #7 from github/refactor-move-render-logic-into-class-renderinto
...
refactor: move `render()` logic into class `renderInto()`
2021-01-19 17:09:08 +00:00
Keith Cirkel
e865f63107
fix(html): Allow for nested text nodes in iterables
...
This changes the API from `children` to `childNodes` because `children`
does not include `Text` nodes.
diff --git src/html.ts src/html.ts
index d0578b1..6fe4502 100644
--- src/html.ts
+++ src/html.ts
@@ -19,7 +19,7 @@ function processSubTemplate(part: TemplatePart, value: unknown): boolean {
function processDocumentFragment(part: TemplatePart, value: unknown): boolean {
if (value instanceof DocumentFragment && part instanceof NodeTemplatePart) {
- part.replace((value as unknown) as ChildNode)
+ if (value.childNodes.length) part.replace(...value.childNodes)
return true
}
return false
diff --git test/html.ts test/html.ts
index 6dbfc6c..0ff3ee2 100644
--- test/html.ts
+++ test/html.ts
@@ -40,6 +40,17 @@ describe('render', () => {
render(main(child('Goodbye')), surface)
expect(surface.innerHTML).to.equal('<div><span>Goodbye</span></div>')
})
+
+ it('can nest document fragments and text nodes', () => {
+ const main = frag => html`<span>${frag}</span>`
+ const fragment = document.createDocumentFragment()
+ fragment.append(new Text('Hello World'))
+ render(main(fragment), surface)
+ expect(surface.innerHTML).to.equal('<span>Hello World</span>')
+ fragment.append(document.createTextNode('Hello Universe!'))
+ render(main(fragment), surface)
+ expect(surface.innerHTML).to.equal('<span>Hello Universe!</span>')
+ })
})
describe('iterables', () => {
2021-01-19 16:59:21 +00:00
Keith Cirkel
00a735fb58
fix(html): Allow for document fragments with text nodes.
...
This changes the API from `children` to `childNodes` because `children`
does not include `Text` nodes.
2021-01-19 16:57:45 +00:00
Keith Cirkel
c76895605b
refactor: move `render()` logic into class `renderInto()`
...
This simplifies the logic of the render function, meaning
`TemplateResult` can be used in a more standalone fashion, by other
libraries, which can integrate just the `html` function, forgoing the
need to import `render` as well.
2021-01-19 12:18:42 +00:00
Keith Cirkel
469b5d51d6
0.2.0
2021-01-19 12:03:31 +00:00
Keith Cirkel
6ee2e64035
Merge pull request #6 from github/docs-readme-add-documentation
...
docs(readme): add documentation
2021-01-19 12:02:04 +00:00
Keith Cirkel
30f8891543
docs(readme): fix typos
2021-01-19 12:01:37 +00:00
Keith Cirkel
e5b2a8bec9
docs(readme): add documentation
2021-01-19 11:53:48 +00:00
Keith Cirkel
532e115f48
Merge pull request #5 from github/feat-add-support-for-iterables-in-templates
...
feat: add support for iterables in templates
2021-01-19 10:11:11 +00:00
Keith Cirkel
97bfffdfa7
refactor(html): use Array.from for clarity
...
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
2021-01-19 10:07:48 +00:00
Keith Cirkel
04593d97a3
feat: add support for iterables in templates
2021-01-18 17:52:39 +00:00
Keith Cirkel
f4ede91097
0.1.2
2021-01-18 15:35:00 +00:00
Keith Cirkel
78a6a053a0
build: publish to github+npm registries
2021-01-18 15:31:25 +00:00
Keith Cirkel
c4ea26a6d8
0.1.1
2021-01-14 17:54:45 +00:00
Keith Cirkel
c7774cf6d0
Merge pull request #3 from github/fix-until-use-correct-call-signature-for-processpart
...
fix(until): use correct call signature for processPart
2021-01-14 17:47:02 +00:00
Keith Cirkel
4c34edfa4d
chore: update team name in CODEOWNERS
2021-01-14 17:46:19 +00:00
Keith Cirkel
b7f9fbf3d9
fix(until): use correct call signature for processPart
2021-01-14 17:43:31 +00:00
Keith Cirkel
8d3faa6397
build: use branch main
2021-01-14 17:30:07 +00:00
Keith Cirkel
4c9e5b0ced
build: add CI
2021-01-14 17:29:02 +00:00
Keith Cirkel
9df9927044
chore: upgrade @github/template-parts@0.3.0
2021-01-14 17:27:38 +00:00
Keith Cirkel
7ff704c277
Merge pull request #2 from github/refactor-decompose-part-processing
...
refactor: decompose part processing
2021-01-14 17:22:06 +00:00
Keith Cirkel
03f564bac1
refactor: decompose part processing
2021-01-14 16:18:22 +00:00
Keith Cirkel
349a99f335
Merge pull request #1 from github/feat-initial-implementation
...
Initial implementation
2020-10-27 13:31:07 +01:00
Keith Cirkel
0838d1136d
docs: use lowercase in README title
...
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
2020-10-27 13:30:57 +01:00
Keith Cirkel
83d52f7992
chore: CODEOWNERS
2020-10-26 15:40:24 +00:00
Keith Cirkel
6f23fc64c3
docs: CODE_OF_CONDUCT
2020-10-26 15:40:16 +00:00