fix(glimmer): treat glimmer components as self closing tags (#4900)

master
Paul Chavard 2018-07-27 12:49:13 +02:00 committed by Jed Fox
parent 556fb3e646
commit 0571b2b884
3 changed files with 31 additions and 5 deletions

View File

@ -47,9 +47,14 @@ function print(path, options, print) {
);
}
case "ElementNode": {
const isVoid = voidTags.indexOf(n.tag) !== -1;
const closeTag = isVoid ? concat([" />", softline]) : ">";
const tagFirstChar = n.tag[0];
const isLocal = n.tag.indexOf(".") !== -1;
const isGlimmerComponent =
tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
const hasChildren = n.children.length > 0;
const isVoid =
(isGlimmerComponent && !hasChildren) || voidTags.indexOf(n.tag) !== -1;
const closeTag = isVoid ? concat([" />", softline]) : ">";
const getParams = (path, print) =>
indent(
concat([

View File

@ -135,9 +135,16 @@ exports[`block-statement.hbs - glimmer-verify 1`] = `
`;
exports[`component.hbs - glimmer-verify 1`] = `
<user-greeting @name="Ricardo" @greeting="Olá" />
<UserGreeting @name="Ricardo" @greeting="Olá" />
{{@greeting}}, {{@name}}!
<Form as |f|>
<f.input @title="hello" />
<f.input>hello</f.input>
</Form>
<this.label @title="hello" />
<button onclick={{action next}}>Next</button>
<button disabled class="disabled"></button>
@ -146,11 +153,18 @@ exports[`component.hbs - glimmer-verify 1`] = `
<div ...attributes>Hello</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<user-greeting @name="Ricardo" @greeting="Olá"></user-greeting>
<UserGreeting @name="Ricardo" @greeting="Olá" />
{{@greeting}}
,
{{@name}}
!
<Form as |f|>
<f.input @title="hello" />
<f.input>
hello
</f.input>
</Form>
<this.label @title="hello" />
<button onclick={{action next}}>
Next
</button>

View File

@ -1,6 +1,13 @@
<user-greeting @name="Ricardo" @greeting="Olá" />
<UserGreeting @name="Ricardo" @greeting="Olá" />
{{@greeting}}, {{@name}}!
<Form as |f|>
<f.input @title="hello" />
<f.input>hello</f.input>
</Form>
<this.label @title="hello" />
<button onclick={{action next}}>Next</button>
<button disabled class="disabled"></button>