Skip to content

Commit 966d944

Browse files
EricSchankrwjblue
authored andcommitted
[BUGFIX release] use bracket notation to access unknown attr #12035
(cherry picked from commit 288f40d)
1 parent c4c5be1 commit 966d944

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

+26
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

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

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

0 commit comments

Comments
 (0)