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

[BUGFIX lts] dont access properties during init unless required #19023

Merged
merged 1 commit into from
Jun 20, 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
4 changes: 2 additions & 2 deletions packages/@ember/-internals/runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ function initialize(obj, properties) {
let isDescriptor = possibleDesc !== undefined;

if (!isDescriptor) {
let baseValue = obj[keyName];

if (hasConcatenatedProps && concatenatedProperties.indexOf(keyName) > -1) {
let baseValue = obj[keyName];
if (baseValue) {
value = makeArray(baseValue).concat(value);
} else {
Expand All @@ -113,6 +112,7 @@ function initialize(obj, properties) {
}

if (hasMergedProps && mergedProperties.indexOf(keyName) > -1) {
let baseValue = obj[keyName];
value = assign({}, baseValue, value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getOwner, setOwner } from '@ember/-internals/owner';
import { get, set, observer } from '@ember/-internals/metal';
import CoreObject from '../../lib/system/core_object';
import { moduleFor, AbstractTestCase, buildOwner, runLoopSettled } from 'internal-test-helpers';
import { track } from '@glimmer/validator';

moduleFor(
'Ember.CoreObject',
Expand Down Expand Up @@ -132,5 +133,24 @@ moduleFor(

test.destroy();
}

['@test native getters/setters do not cause rendering invalidation during init'](assert) {
let objectMeta = Object.create(null);

class TestObject extends CoreObject {
get hiddenValue() {
let v = get(objectMeta, 'hiddenValue');
return v !== undefined ? v : false;
}
set hiddenValue(v) {
set(objectMeta, 'hiddenValue', v);
}
}

track(() => {
TestObject.create({ hiddenValue: true });
assert.ok(true, 'We did not error');
});
}
}
);