From 4e442b769bd3e61065cc32df2cd59cfba51fb188 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Fri, 13 Dec 2024 11:12:08 -0500 Subject: [PATCH 1/2] Add test coverage for both built-in processor strategies Existing test coverage lacked tests that exercised _both_ the default `processPropertyIdentity` strategy alongside the optional `propertyIdentityOrBooleanAttribute` strategy. This commit doesn't contain any implementation changes, but broadens test coverage instead. --- test/template-instance.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/template-instance.ts b/test/template-instance.ts index 76e691a..fac7297 100644 --- a/test/template-instance.ts +++ b/test/template-instance.ts @@ -28,14 +28,32 @@ describe('template-instance', () => { root.appendChild(instance) expect(root.innerHTML).to.equal(`
Hello world
`) }) - it('applies data to nested templated element nodes', () => { + it('applies data to nested templated element nodes with the default processPropertyIdentity', () => { const root = document.createElement('div') const template = Object.assign(document.createElement('template'), { innerHTML: '', }) - root.appendChild(new TemplateInstance(template, {x: 'Hello world'})) + const instance = new TemplateInstance(template, {x: 'Hello world'}) + root.appendChild(instance) expect(root.innerHTML).to.equal('') + expect(template.innerHTML).to.equal('') + instance.update({x: 'Goodbye world'}) + expect(root.innerHTML).to.equal('') + expect(template.innerHTML).to.equal('') + }) + it('applies data to nested templated element nodes with propertyIdentityOrBooleanAttribute', () => { + const template = Object.assign(document.createElement('template'), { + innerHTML: '', + }) + const instance = new TemplateInstance(template, {hidden: true}, propertyIdentityOrBooleanAttribute) + + const root = document.createElement('div') + root.appendChild(instance) + expect(root.innerHTML).to.equal('') + expect(template.innerHTML).to.equal('') + instance.update({hidden: false}) + expect(root.innerHTML).to.equal('') }) it('applies data to templated DocumentFragment nodes', () => { const template = document.createElement('template') @@ -357,7 +375,7 @@ describe('template-instance', () => { }) describe('handling InnerTemplatePart', () => { - it('makes outer state available to inner parts', () => { + it('makes outer state available to InnerTemplatePart elements with [directive]', () => { const processor = createProcessor((part, value, state) => { if (part instanceof InnerTemplatePart && part.directive === 'if') { if (typeof state === 'object' && (state as Record)[part.expression]) { From b98aa52203f2fe88b3fb41e9f207a3e35c060fef Mon Sep 17 00:00:00 2001 From: Leslie Cohn-Wein Date: Fri, 10 Jan 2025 11:59:26 -0600 Subject: [PATCH 2/2] Update CODEOWNERS to Web Systems --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 68f394d..e6bf555 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @github/primer-reviewers +* @github/web-systems-reviewers