Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make in-element a public construct #619

Merged
merged 1 commit into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/@glimmer/runtime/lib/syntax/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ export function populateBuiltins(blocks: Blocks = new Blocks(), inlines: Inlines
builder.stopLabels();
});

blocks.add('-in-element', (params, hash, template, _inverse, builder) => {
blocks.add('in-element', (params, hash, template, _inverse, builder) => {
if (!params || params.length !== 1) {
throw new Error(`SYNTAX ERROR: #-in-element requires a single argument`);
throw new Error(`SYNTAX ERROR: #in-element requires a single argument`);
}

builder.startLabels();
Expand All @@ -714,7 +714,7 @@ export function populateBuiltins(blocks: Blocks = new Blocks(), inlines: Inlines
if (keys.length === 1 && keys[0] === 'nextSibling') {
expr(values[0], builder);
} else {
throw new Error(`SYNTAX ERROR: #-in-element does not take a \`${keys[0]}\` option`);
throw new Error(`SYNTAX ERROR: #in-element does not take a \`${keys[0]}\` option`);
}
} else {
expr(null, builder);
Expand Down
40 changes: 20 additions & 20 deletions packages/@glimmer/runtime/test/in-element-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { setProperty as set } from '@glimmer/object-reference';
class InElementTests extends RenderTests {
@test "Renders curlies into external element"() {
let externalElement = document.createElement("div");
this.render("{{#-in-element externalElement}}[{{foo}}]{{/-in-element}}", { externalElement, foo: "Yippie!" });
this.render("{{#in-element externalElement}}[{{foo}}]{{/in-element}}", { externalElement, foo: "Yippie!" });
equalsElement(externalElement, "div", {}, "[Yippie!]");
this.assertStableRerender();

Expand All @@ -32,8 +32,8 @@ class InElementTests extends RenderTests {
this.render(
stripTight`
|{{foo}}|
{{#-in-element first}}[{{foo}}]{{/-in-element}}
{{#-in-element second}}[{{foo}}]{{/-in-element}}
{{#in-element first}}[{{foo}}]{{/in-element}}
{{#in-element second}}[{{foo}}]{{/in-element}}
`,
{ first, second: null, foo: "Yippie!" }
);
Expand Down Expand Up @@ -73,7 +73,7 @@ class InElementTests extends RenderTests {
let initialContent = externalElement.innerHTML = "<p>Hello there!</p>";

this.render(
stripTight`{{#-in-element externalElement}}[{{foo}}]{{/-in-element}}`,
stripTight`{{#in-element externalElement}}[{{foo}}]{{/in-element}}`,
{ externalElement, foo: "Yippie!" }
);

Expand Down Expand Up @@ -102,7 +102,7 @@ class InElementTests extends RenderTests {
externalElement.innerHTML = "<b>Hello</b><em>there!</em>";

this.render(
stripTight`{{#-in-element externalElement nextSibling=nextSibling}}[{{foo}}]{{/-in-element}}`,
stripTight`{{#in-element externalElement nextSibling=nextSibling}}[{{foo}}]{{/in-element}}`,
{ externalElement, nextSibling: externalElement.lastChild, foo: "Yippie!" }
);

Expand Down Expand Up @@ -136,7 +136,7 @@ class InElementTests extends RenderTests {
let second = document.createElement("div");

this.render(
stripTight`{{#-in-element externalElement}}[{{foo}}]{{/-in-element}}`,
stripTight`{{#in-element externalElement}}[{{foo}}]{{/in-element}}`,
{ externalElement: first, foo: "Yippie!" }
);

Expand Down Expand Up @@ -189,10 +189,10 @@ class InElementTests extends RenderTests {
this.render(
stripTight`
{{#if showFirst}}
{{#-in-element first}}[{{foo}}]{{/-in-element}}
{{#in-element first}}[{{foo}}]{{/in-element}}
{{/if}}
{{#if showSecond}}
{{#-in-element second}}[{{foo}}]{{/-in-element}}
{{#in-element second}}[{{foo}}]{{/in-element}}
{{/if}}
`,
{
Expand Down Expand Up @@ -252,12 +252,12 @@ class InElementTests extends RenderTests {

this.render(
stripTight`
{{#-in-element firstElement}}
{{#in-element firstElement}}
[{{foo}}]
{{/-in-element}}
{{#-in-element secondElement}}
{{/in-element}}
{{#in-element secondElement}}
[{{bar}}]
{{/-in-element}}
{{/in-element}}
`,
{
firstElement,
Expand Down Expand Up @@ -303,9 +303,9 @@ class InElementTests extends RenderTests {
this.render(
stripTight`
{{~#each roots key="id" as |root|~}}
{{~#-in-element root.element ~}}
{{~#in-element root.element ~}}
{{component 'FooBar' value=root.value}}
{{~/-in-element~}}
{{~/in-element~}}
{{~/each}}
`,
{
Expand Down Expand Up @@ -351,12 +351,12 @@ class InElementTests extends RenderTests {

this.render(
stripTight`
{{#-in-element firstElement}}
{{#in-element firstElement}}
[{{foo}}]
{{#-in-element secondElement}}
{{#in-element secondElement}}
[{{bar}}]
{{/-in-element}}
{{/-in-element}}
{{/in-element}}
{{/in-element}}
`,
{
firstElement,
Expand Down Expand Up @@ -410,7 +410,7 @@ class InElementTests extends RenderTests {
this.render(
stripTight`
{{#if showExternal}}
{{#-in-element externalElement}}[<DestroyMe />]{{/-in-element}}
{{#in-element externalElement}}[<DestroyMe />]{{/in-element}}
{{/if}}
`,
{
Expand Down Expand Up @@ -438,4 +438,4 @@ class InElementTests extends RenderTests {
}
};

module("#-in-element Test", InElementTests);
module("#in-element Test", InElementTests);
4 changes: 2 additions & 2 deletions packages/@glimmer/runtime/test/updating-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,11 @@ module("[glimmer-runtime] Updating", hooks => {
testStatefulHelper(assert, options);
});

test(`helpers passed as arguments to {{#-in-element}} are not torn down when switching between blocks`, assert => {
test(`helpers passed as arguments to {{#in-element}} are not torn down when switching between blocks`, assert => {
let externalElement = document.createElement('div');

let options = {
template: '{{#-in-element (stateful-foo)}}Yes{{/-in-element}}',
template: '{{#in-element (stateful-foo)}}Yes{{/in-element}}',
truthyValue: externalElement,
falsyValue: null,
element: externalElement
Expand Down