Skip to content

Commit

Permalink
Merge pull request #12071 from EricSchank/unspecified-comp-attrs
Browse files Browse the repository at this point in the history
[BUGFIX release] use bracket notation to access unknown attr #12035
  • Loading branch information
rwjblue committed Aug 13, 2015
2 parents 4a8d9a3 + 288f40d commit 6c78b25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/ember-htmlbars/tests/integration/attrs_lookup_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,29 @@ QUnit.test('should be able to modify a provided attr into local state #11571 / #
equal(view.$().text(), 'FIRST ATTR', 'template lookup uses local state');
equal(component.get('first'), 'FIRST ATTR', 'component lookup uses local state');
});

QUnit.test('should be able to access unspecified attr #12035', function() {
var component;

registry.register('component:foo-bar', Component.extend({
init() {
this._super(...arguments);
component = this;
},

didReceiveAttrs() {
equal(this.get('woot'), 'yes', 'found attr in didReceiveAttrs');
}
}));
// registry.register('template:components/foo-bar', compile('{{first}}'));

view = EmberView.extend({
template: compile('{{foo-bar woot="yes"}}'),
container: container
}).create();

runAppend(view);

// equal(view.$().text(), 'FIRST ATTR', 'template lookup uses local state');
equal(component.get('woot'), 'yes', 'component found attr');
});
2 changes: 1 addition & 1 deletion packages/ember-views/lib/compat/attrs-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let AttrsProxyMixin = {
// do not deprecate accessing `this[key]` at this time.
// add this back when we have a proper migration path
// Ember.deprecate(deprecation(key), { id: 'ember-views.', until: '3.0.0' });
let possibleCell = attrs.key;
let possibleCell = attrs[key];

if (possibleCell && possibleCell[MUTABLE_CELL]) {
return possibleCell.value;
Expand Down

0 comments on commit 6c78b25

Please sign in to comment.