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

[GLIMMER] Prevent auto-run assertion for objects not rendered. #14093

Merged
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
9 changes: 6 additions & 3 deletions packages/ember-metal/lib/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ if (hasGlimmer) {
makeTag = () => new DirtyableTag();

markObjectAsDirty = function(meta) {
ensureRunloop();
let tag = (meta && meta.readableTag()) || CURRENT_TAG;
tag.dirty();
let tag = meta && meta.readableTag();

if (tag) {
ensureRunloop();
tag.dirty();
}
};
} else {
markObjectAsDirty = function() {};
Expand Down
16 changes: 15 additions & 1 deletion packages/ember-metal/tests/accessors/set_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { setHasViews } from 'ember-metal/tags';

QUnit.module('set');
QUnit.module('set', {
teardown() {
setHasViews(() => false);
}
});

QUnit.test('should set arbitrary properties on an object', function() {
let obj = {
Expand Down Expand Up @@ -69,3 +74,12 @@ QUnit.test('warn on attempts of calling set on a destroyed object', function() {

expectAssertion(() => set(obj, 'favoriteFood', 'hot dogs'), 'calling set on destroyed object: [object Object].favoriteFood = hot dogs');
});

QUnit.test('does not trigger auto-run assertion for objects that have not been tagged', function(assert) {
setHasViews(() => true);
let obj = {};

set(obj, 'foo', 'bar');

assert.equal(obj.foo, 'bar');
});