Skip to content

Commit 288f40d

Browse files
committed
[BUGFIX release] use bracket notation to access unknown attr #12035
1 parent 4a8d9a3 commit 288f40d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/ember-htmlbars/tests/integration/attrs_lookup_test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,29 @@ QUnit.test('should be able to modify a provided attr into local state #11571 / #
8282
equal(view.$().text(), 'FIRST ATTR', 'template lookup uses local state');
8383
equal(component.get('first'), 'FIRST ATTR', 'component lookup uses local state');
8484
});
85+
86+
QUnit.test('should be able to access unspecified attr #12035', function() {
87+
var component;
88+
89+
registry.register('component:foo-bar', Component.extend({
90+
init() {
91+
this._super(...arguments);
92+
component = this;
93+
},
94+
95+
didReceiveAttrs() {
96+
equal(this.get('woot'), 'yes', 'found attr in didReceiveAttrs');
97+
}
98+
}));
99+
// registry.register('template:components/foo-bar', compile('{{first}}'));
100+
101+
view = EmberView.extend({
102+
template: compile('{{foo-bar woot="yes"}}'),
103+
container: container
104+
}).create();
105+
106+
runAppend(view);
107+
108+
// equal(view.$().text(), 'FIRST ATTR', 'template lookup uses local state');
109+
equal(component.get('woot'), 'yes', 'component found attr');
110+
});

packages/ember-views/lib/compat/attrs-proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ let AttrsProxyMixin = {
7070
// do not deprecate accessing `this[key]` at this time.
7171
// add this back when we have a proper migration path
7272
// Ember.deprecate(deprecation(key), { id: 'ember-views.', until: '3.0.0' });
73-
let possibleCell = attrs.key;
73+
let possibleCell = attrs[key];
7474

7575
if (possibleCell && possibleCell[MUTABLE_CELL]) {
7676
return possibleCell.value;

0 commit comments

Comments
 (0)