Skip to content

Commit

Permalink
Merge pull request #1459 from patricklx/revert-1447-patch-3
Browse files Browse the repository at this point in the history
Revert "fix: capture render tree can fail if args cannot be obtained"
  • Loading branch information
NullVoxPopuli committed Oct 24, 2023
2 parents 6d35de3 + c166ef2 commit 678c15d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,19 @@ class DebugRenderTreeTest extends RenderTest {

@test 'emberish curly components'() {
this.registerComponent('Curly', 'HelloWorld', 'Hello World');
let error: Error|null = null;
const obj = {
get getterWithError() {
error = new Error('error');
throw error;
}
}

this.render(
`<HelloWorld @arg="first" @arg2={{this.obj.getterWithError}}/>{{#if this.showSecond}}<HelloWorld @arg="second"/>{{/if}}`,
`<HelloWorld @arg="first"/>{{#if this.showSecond}}<HelloWorld @arg="second"/>{{/if}}`,
{
showSecond: false,
obj,
}
);

this.assert.ok(error !== null, 'expecting an Error');

this.assertRenderTree([
{
type: 'component',
name: 'HelloWorld',
args: { positional: [], named: { arg: 'first', arg2: error } },
args: { positional: [], named: { arg: 'first' } },
instance: (instance: EmberishCurlyComponent) => (instance as any).arg === 'first',
template: '(unknown template module)',
bounds: this.nodeBounds(this.delegate.getInitialElement().firstChild),
Expand All @@ -174,7 +164,7 @@ class DebugRenderTreeTest extends RenderTest {
{
type: 'component',
name: 'HelloWorld',
args: { positional: [], named: { arg: 'first', arg2: error } },
args: { positional: [], named: { arg: 'first' } },
instance: (instance: EmberishCurlyComponent) => (instance as any).arg === 'first',
template: '(unknown template module)',
bounds: this.nodeBounds(this.element.firstChild),
Expand All @@ -197,7 +187,7 @@ class DebugRenderTreeTest extends RenderTest {
{
type: 'component',
name: 'HelloWorld',
args: { positional: [], named: { arg: 'first', arg2: error } },
args: { positional: [], named: { arg: 'first' } },
instance: (instance: EmberishCurlyComponent) => (instance as any).arg === 'first',
template: '(unknown template module)',
bounds: this.nodeBounds(this.element.firstChild),
Expand Down
14 changes: 2 additions & 12 deletions packages/@glimmer/runtime/lib/vm/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,24 +483,14 @@ export function reifyNamed(named: CapturedNamedArguments) {
let reified = dict();

for (const [key, value] of Object.entries(named)) {
try {
reified[key] = valueForRef(value);
} catch(e) {
reified[key] = e;
}
reified[key] = valueForRef(value);
}

return reified;
}

export function reifyPositional(positional: CapturedPositionalArguments) {
return positional.map((p) => {
try {
return valueForRef(p);
} catch(e) {
return e;
}
});
return positional.map(valueForRef);
}

export function reifyArgs(args: CapturedArguments) {
Expand Down

0 comments on commit 678c15d

Please sign in to comment.