Skip to content

Commit

Permalink
Merge pull request #14093 from emberjs/prevent-auto-run-assertions-fo…
Browse files Browse the repository at this point in the history
…r-objects-not-in-templates

[GLIMMER] Prevent auto-run assertion for objects not rendered.
  • Loading branch information
rwjblue authored Aug 19, 2016
2 parents e150088 + 533e8aa commit 938ad1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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');
});

0 comments on commit 938ad1a

Please sign in to comment.