Skip to content

Commit

Permalink
fix: using ...attributes without passing attrs fails
Browse files Browse the repository at this point in the history
Example:
A component template with:
```hbs
<div ...attributes></div>
```
and this invocation:
```hbs
<MyComponent />
```
fails with:
```
Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.create (runtime-polyfill.js:99)
```
This invocation succeeds:
```hbs
<MyComponent class="foo" />
```
  • Loading branch information
lennyburdette authored and Lenny Burdette committed Jul 11, 2018
1 parent 139b986 commit d58f072
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions tests/integration/components/angle-bracket-invocation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,16 @@ module('Integration | Component | angle-bracket-invocation', function(hooks) {

assert.dom('span[data-test-my-thing]').hasText('hi martin!');
});

test('passing into element - unused', async function(assert) {
this.owner.register(
'template:components/foo-bar',
hbs`<span ...attributes>hi martin!</span>`
);

await render(hbs`<FooBar />`);

assert.dom('span').hasText('hi martin!');
});
});
});
4 changes: 2 additions & 2 deletions vendor/angle-bracket-invocation-polyfill/runtime-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import { lte, gte } from 'ember-compatibility-helpers';
let { positional } = args.capture();
let invocationAttributesReference = positional.at(0);
let invocationAttributes = invocationAttributesReference.value();
let attributeNames = Object.keys(invocationAttributes);
let attributeNames = invocationAttributes ? Object.keys(invocationAttributes) : [];
let dynamicAttributes = {};

for (let i = 0; i < attributeNames.length; i++) {
Expand Down Expand Up @@ -235,7 +235,7 @@ import { lte, gte } from 'ember-compatibility-helpers';
let positional = gte('2.15.0-beta.1') ? args.capture().positional : args.positional;
let invocationAttributesReference = positional.at(0);
let invocationAttributes = invocationAttributesReference.value();
let attributeNames = Object.keys(invocationAttributes);
let attributeNames = invocationAttributes ? Object.keys(invocationAttributes) : [];
let dynamicAttributes = {};

for (let i = 0; i < attributeNames.length; i++) {
Expand Down

0 comments on commit d58f072

Please sign in to comment.