Skip to content

Commit

Permalink
Merge pull request #68 from simonihmig/fix-no-value
Browse files Browse the repository at this point in the history
Fix unused splattributes being passed to component
  • Loading branch information
rwjblue authored May 8, 2019
2 parents b66f1cc + 954de84 commit bcd306f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
9 changes: 9 additions & 0 deletions tests/integration/components/angle-bracket-invocation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,15 @@ module('Integration | Component | angle-bracket-invocation', function(hooks) {
assert.dom('[data-one="from render"][data-two="from outer"]').hasText('hi martin!');
});

test('passing into angle invocation - unused', async function(assert) {
this.owner.register('template:components/comp-outer', hbs`<CompInner ...attributes />`);
this.owner.register('template:components/comp-inner', hbs`hi martin!`);

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

assert.dom('div div').hasText('hi martin!');
});

test('passing into element - normal component', async function(assert) {
this.owner.register(
'template:components/foo-bar',
Expand Down
35 changes: 20 additions & 15 deletions vendor/angle-bracket-invocation-polyfill/runtime-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ import { lte, gte } from 'ember-compatibility-helpers';
let angleAttrs = args.get('__ANGLE_ATTRS__');
// this use of value is OK because the set of keys isn't allowed to change dynamically
let snapshot = angleAttrs.value();
for (let attributeName in snapshot) {
let attributeReference = angleAttrs.get(attributeName);
operations.setAttribute(attributeName, attributeReference, false, null);
if (snapshot) {
for (let attributeName in snapshot) {
let attributeReference = angleAttrs.get(attributeName);
operations.setAttribute(attributeName, attributeReference, false, null);
}
}
}
};
Expand Down Expand Up @@ -382,18 +384,21 @@ import { lte, gte } from 'ember-compatibility-helpers';
// on < 2.15 `namedArgs` is only present when there were arguments
if (args && args.has('__ANGLE_ATTRS__')) {
let attributeReferences = args.get('__ANGLE_ATTRS__');
let names = Object.keys(attributeReferences.value());
for (let i = 0; i < names.length; i++) {
let attributeName = names[i];
let attributeReference = attributeReferences.get(attributeName);

operations.addDynamicAttribute(
element,
attributeName,
attributeReference,
false,
null
);
let snapshot = attributeReferences.value();
if (snapshot) {
let names = Object.keys(snapshot);
for (let i = 0; i < names.length; i++) {
let attributeName = names[i];
let attributeReference = attributeReferences.get(attributeName);

operations.addDynamicAttribute(
element,
attributeName,
attributeReference,
false,
null
);
}
}
}
};
Expand Down

0 comments on commit bcd306f

Please sign in to comment.