From 19c135bd4bc1f6a3c8bda715ff70ff3eeb0e969a Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 11 May 2022 20:08:22 +0000 Subject: [PATCH 1/7] fix tsconfig.build.json test path --- tsconfig.build.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.build.json b/tsconfig.build.json index f4b9da6..2ab0489 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,5 +1,5 @@ { - "exclude": ["__tests__"], + "exclude": ["test"], "extends": "./tsconfig.json", "compilerOptions": { "declaration": true, From 0a553f7d12bc971030d16b11ccb44070d92c73cb Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 23 Sep 2022 17:57:00 +0100 Subject: [PATCH 2/7] move AOR to primer --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 5b436b7..68f394d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @github/ui-frameworks-reviewers +* @github/primer-reviewers From f23ffc277cf3eb82b472cb1909656cb7fa68f3b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Nov 2022 03:55:44 +0000 Subject: [PATCH 3/7] build(deps): bump minimatch from 3.0.4 to 3.1.2 Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6644b16..f689e3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4623,9 +4623,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -10070,9 +10070,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" From 14ce756117ba27dee62cec3e306d7e9b35af85da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 05:07:32 +0000 Subject: [PATCH 4/7] build(deps): bump qs from 6.7.0 to 6.11.0 Bumps [qs](https://github.com/ljharb/qs) from 6.7.0 to 6.11.0. - [Release notes](https://github.com/ljharb/qs/releases) - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.7.0...v6.11.0) --- updated-dependencies: - dependency-name: qs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index f689e3d..cd6e1b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5248,12 +5248,18 @@ } }, "node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/queue-microtask": { @@ -10548,10 +10554,13 @@ } }, "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "requires": { + "side-channel": "^1.0.4" + } }, "queue-microtask": { "version": "1.2.3", From f6ab0f37695cf9060de03302a631405395e768ac Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Sun, 11 Dec 2022 23:22:49 -0500 Subject: [PATCH 5/7] Extend `processPropertyIdentity` to handle Element Closes [github/template-parts#62][] Extends the `processPropertyIdentity` function from the `processors` module to pass-through `Element` instances, instead of coercing them through calls to `String()`. In order to accommodate that change, this commit also extends the `TemplatePart` interface to accept `Element` instances for its `value:` property. The change to the `createTreeWalker` invocation within `collectParts` was highlighted by TypeScript, as the final `boolean` argument doesn't conform to the [createTreeWalker][] signature. It was a necessary change to build the project and execute the test suite locally. [github/template-parts#62]: https://github.com/github/template-parts/issues/62 [createTreeWalker]: https://developer.mozilla.org/en-US/docs/Web/API/Document/createTreeWalker --- src/processors.ts | 2 +- src/template-instance.ts | 2 +- src/types.ts | 2 +- test/template-instance.ts | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/processors.ts b/src/processors.ts index d50c06c..0c2cb7c 100644 --- a/src/processors.ts +++ b/src/processors.ts @@ -19,7 +19,7 @@ export function createProcessor(processPart: PartProcessor): TemplateTypeInit { } export function processPropertyIdentity(part: TemplatePart, value: unknown): void { - part.value = String(value) + part.value = value instanceof Element ? value : String(value) } export function processBooleanAttribute(part: TemplatePart, value: unknown): boolean { diff --git a/src/template-instance.ts b/src/template-instance.ts index ddf8910..4e6ce0c 100644 --- a/src/template-instance.ts +++ b/src/template-instance.ts @@ -5,7 +5,7 @@ import {propertyIdentity} from './processors.js' import {TemplatePart, TemplateTypeInit} from './types.js' function* collectParts(el: DocumentFragment): Generator { - const walker = el.ownerDocument.createTreeWalker(el, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, null, false) + const walker = el.ownerDocument.createTreeWalker(el, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, null) let node while ((node = walker.nextNode())) { if (node instanceof Element && node.hasAttributes()) { diff --git a/src/types.ts b/src/types.ts index 1170530..a5c2520 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ import type {TemplateInstance} from './template-instance.js' export interface TemplatePart { expression: string - value: string | null + value: Element | string | null } type TemplateProcessCallback = (instance: TemplateInstance, parts: Iterable, params: unknown) => void diff --git a/test/template-instance.ts b/test/template-instance.ts index b4f65af..1c5e8ea 100644 --- a/test/template-instance.ts +++ b/test/template-instance.ts @@ -14,6 +14,19 @@ describe('template-instance', () => { root.appendChild(instance) expect(root.innerHTML).to.equal(`Hello world`) }) + it('applies data to templated element nodes', () => { + const template = document.createElement('template') + const element = Object.assign(document.createElement('div'), { + innerHTML: 'Hello world' + }) + const originalHTML = `{{x}}` + template.innerHTML = originalHTML + const instance = new TemplateInstance(template, {x: element}) + expect(template.innerHTML).to.equal(originalHTML) + const root = document.createElement('div') + root.appendChild(instance) + expect(root.innerHTML).to.equal(`
Hello world
`) + }) it('can render into partial text nodes', () => { const template = document.createElement('template') const originalHTML = `Hello {{x}}!` From f3aa800479801e3e7a0ad66fd26af3bb0ab5b5d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Jan 2023 05:02:44 +0000 Subject: [PATCH 6/7] build(deps): bump json5 from 2.2.0 to 2.2.3 Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index f689e3d..00385a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4147,13 +4147,10 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, "bin": { "json5": "lib/cli.js" }, @@ -9677,13 +9674,10 @@ "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true }, "keygrip": { "version": "1.1.0", From 243ef6272d798286778ab52a4f5def4b42eec40e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 16:19:31 +0000 Subject: [PATCH 7/7] build(deps): bump ua-parser-js from 1.0.2 to 1.0.33 Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 1.0.2 to 1.0.33. - [Release notes](https://github.com/faisalman/ua-parser-js/releases) - [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md) - [Commits](https://github.com/faisalman/ua-parser-js/compare/1.0.2...1.0.33) --- updated-dependencies: - dependency-name: ua-parser-js dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 990221e..0e99d43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6134,9 +6134,9 @@ } }, "node_modules/ua-parser-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", - "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==", + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", "dev": true, "funding": [ { @@ -11199,9 +11199,9 @@ "dev": true }, "ua-parser-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", - "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==", + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", "dev": true }, "unbox-primitive": {