Граф коммитов

72 Коммитов

Автор SHA1 Сообщение Дата
Kristján Oddsson b307e5aced Create .github/workflows/publish.yml 2022-03-25 19:21:00 +00:00
Keith Cirkel 5a7c911fb0
Update package.json 2022-03-23 15:44:20 +00:00
Keith Cirkel 59d18fe3f7
Merge pull request #19 from github/refactor
Refactor
2022-03-23 12:29:47 +00:00
Keith Cirkel 0dbafd31fa
allow processor to be readable 2022-03-23 12:20:25 +00:00
Keith Cirkel 7cf88ae61c
upgrade tests to use TypeScript 2022-03-23 12:20:13 +00:00
Keith Cirkel 1a2bff2aa3
update tsconfig compile 2022-03-23 12:19:41 +00:00
Keith Cirkel 3feed17621
prettier 2022-03-23 12:19:20 +00:00
Keith Cirkel 0a49398c7b
disable some lint rules 2022-03-23 12:18:20 +00:00
Keith Cirkel b3b403fa75
update all dependencies 2022-03-23 12:18:11 +00:00
Keith Cirkel 7455cb0486
move all functions to their own files
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
2022-03-23 10:19:16 +00:00
Keith Cirkel 2237f9047b
npm i 2022-03-23 10:16:35 +00:00
Jonathan Fuchs 740fdf77e4
Merge pull request #17 from shawnbot/patch-1
Fix vanillaEmbolden reference in document fragment example
2022-01-31 10:59:14 -08:00
Shawn Allen 4db7676672
fix(docs): fix vanillaEmbolden in fragment example 2022-01-28 15:02:18 -08:00
Dusty Greif b7b956cbe3 0.4.1 2022-01-26 14:26:04 +00:00
Dusty Greif 1021c3b8c9
Merge pull request #16 from github/chrome-bin
Use `chromium` package to run karma tests
2022-01-26 07:23:40 -07:00
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