Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKPORT LTS] do not throw on stable elementId #18810

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,39 @@ moduleFor(
}
}

['@test elementId is stable when other values change']() {
let changingArg = 'arbitrary value';
let parentInstance;
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
init() {
this._super(...arguments);
parentInstance = this;
},
changingArg: changingArg,
}),
template: '{{quux-baz elementId="stable-id" changingArg=this.changingArg}}',
});

this.registerComponent('quux-baz', {
ComponentClass: Component.extend({}),
template: '{{changingArg}}',
});

this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild.firstChild, {
attrs: { id: 'stable-id' },
content: 'arbitrary value',
});

changingArg = 'a different value';
runTask(() => set(parentInstance, 'changingArg', changingArg));
this.assertComponentElement(this.firstChild.firstChild, {
attrs: { id: 'stable-id' },
content: changingArg,
});
}

['@test can specify template with `layoutName` property']() {
let FooBarComponent = Component.extend({
elementId: 'blahzorz',
Expand Down
6 changes: 4 additions & 2 deletions packages/@ember/-internals/views/lib/views/states/in_dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ const inDOM = assign({}, hasElement, {
get() {
return elementId;
},
set() {
throw new EmberError("Changing a view's elementId after creation is not allowed");
set(value) {
if (value !== elementId) {
throw new EmberError("Changing a view's elementId after creation is not allowed");
}
},
});
}
Expand Down