From 41b02dbf39a1af3cbcbd7f596786eabf1016936b Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Wed, 29 Apr 2020 14:13:23 -0700 Subject: [PATCH 1/3] Revise RFC #389 with details about its argument --- text/0389-dynamic-tag-names.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/text/0389-dynamic-tag-names.md b/text/0389-dynamic-tag-names.md index 7ec18e78ad..5863dc8c17 100644 --- a/text/0389-dynamic-tag-names.md +++ b/text/0389-dynamic-tag-names.md @@ -43,14 +43,29 @@ With the `element` helper proposed in this RFC, this can be accomplished with so ## Detailed design -We propose to add a new `element` helper that takes a tag name and generates a contextual component that, when invoked, renders the selected element. +We propose to add a new `element` helper that takes a single positional argument. + +* When passed a non-empty string it will generates a contextual component that, when invoked, renders an element with the same tag name as the passed string, along with the passed attributes (if any) and yields to given block (if any). +* When passed an empty string, it will generates a contextual compoment that, when invoked, yields to the given block without wrapping it an element and ignores any passed attributes. +* When passed `null` or `undefined`, it will return `null`. +* When passed any other values (e.g. a boolean or a number), it will result in a development mode assertion. Example: ```hbs {{#let (element @htmlTag) as |Tag|}} - ... + Hello {{/let}} + +{{!-- when @htmlTag="div" --}} +
Hello
+ +{{!-- when @htmlTag="" --}} +Hello + +{{!-- when @htmlTag=null or @htmlTag=undefined, it renders nothing --}} + +{{!-- when @htmlTag=true or @htmlTag=1, it throws in development mode --}} ``` Unlike ids, classes or other attributes, the tag name of DOM element cannot be changed in runtime. From 2bce53048e5548a55f3ed2d3461258b8300f7b42 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Wed, 29 Apr 2020 14:18:27 -0700 Subject: [PATCH 2/3] Mention modifiers as well --- text/0389-dynamic-tag-names.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/text/0389-dynamic-tag-names.md b/text/0389-dynamic-tag-names.md index 5863dc8c17..5447579012 100644 --- a/text/0389-dynamic-tag-names.md +++ b/text/0389-dynamic-tag-names.md @@ -45,8 +45,8 @@ With the `element` helper proposed in this RFC, this can be accomplished with so We propose to add a new `element` helper that takes a single positional argument. -* When passed a non-empty string it will generates a contextual component that, when invoked, renders an element with the same tag name as the passed string, along with the passed attributes (if any) and yields to given block (if any). -* When passed an empty string, it will generates a contextual compoment that, when invoked, yields to the given block without wrapping it an element and ignores any passed attributes. +* When passed a non-empty string it will generates a contextual component that, when invoked, renders an element with the same tag name as the passed string, along with the passed attributes (if any), modifiers (if any) and yields to given block (if any). +* When passed an empty string, it will generates a contextual compoment that, when invoked, yields to the given block without wrapping it an element and ignores any passed modifiers and attributes. * When passed `null` or `undefined`, it will return `null`. * When passed any other values (e.g. a boolean or a number), it will result in a development mode assertion. @@ -54,11 +54,11 @@ Example: ```hbs {{#let (element @htmlTag) as |Tag|}} - Hello + Hello {{/let}} -{{!-- when @htmlTag="div" --}} -
Hello
+{{!-- when @htmlTag="button" --}} + {{!-- when @htmlTag="" --}} Hello From e9836987bc5dc5e7e2c84e8d6b090195d880b1bb Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 30 Apr 2020 18:35:28 -0700 Subject: [PATCH 3/3] Fix typos, round 1 of 57 --- text/0389-dynamic-tag-names.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text/0389-dynamic-tag-names.md b/text/0389-dynamic-tag-names.md index 5447579012..a459993aab 100644 --- a/text/0389-dynamic-tag-names.md +++ b/text/0389-dynamic-tag-names.md @@ -45,8 +45,8 @@ With the `element` helper proposed in this RFC, this can be accomplished with so We propose to add a new `element` helper that takes a single positional argument. -* When passed a non-empty string it will generates a contextual component that, when invoked, renders an element with the same tag name as the passed string, along with the passed attributes (if any), modifiers (if any) and yields to given block (if any). -* When passed an empty string, it will generates a contextual compoment that, when invoked, yields to the given block without wrapping it an element and ignores any passed modifiers and attributes. +* When passed a non-empty string it generates a contextual component that, when invoked, renders an element with the same tag name as the passed string, along with the passed attributes (if any), modifiers (if any) and yields to given block (if any). +* When passed an empty string, it generates a contextual compoment that, when invoked, yields to the given block without wrapping it an element and ignores any passed modifiers and attributes. * When passed `null` or `undefined`, it will return `null`. * When passed any other values (e.g. a boolean or a number), it will result in a development mode assertion.