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

remove rewatch #9323

Merged
merged 1 commit into from
Nov 1, 2014
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
28 changes: 1 addition & 27 deletions packages/ember-metal/lib/watching.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
*/

import {
GUID_KEY,
typeOf,
generateGuid
typeOf
} from "ember-metal/utils";
import {
removeChainWatcher,
Expand Down Expand Up @@ -68,30 +66,6 @@ export function unwatch(obj, _keyPath, m) {
}
}

/**
Call on an object when you first beget it from another object. This will
setup any chained watchers on the object instance as needed. This method is
safe to call multiple times.

@private
@method rewatch
@for Ember
@param obj
*/
export function rewatch(obj) {
var m = obj['__ember_meta__'], chains = m && m.chains;

// make sure the object has its own guid.
if (GUID_KEY in obj && !obj.hasOwnProperty(GUID_KEY)) {
generateGuid(obj);
}

// make sure any chained watchers update.
if (chains && chains.value() !== obj) {
m.chains = chains.copy(obj);
}
}

var NODE_STACK = [];

/**
Expand Down
27 changes: 0 additions & 27 deletions packages/ember-metal/tests/binding/connect_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import {
bind
} from "ember-metal/binding";
import run from 'ember-metal/run_loop';
import { create } from 'ember-metal/platform';
import { set } from 'ember-metal/property_set';
import { get } from 'ember-metal/property_get';
import { rewatch } from "ember-metal/watching";

function performTest(binding, a, b, get, set, connect) {
if (connect === undefined) connect = function() {binding.connect(a);};
Expand Down Expand Up @@ -104,31 +102,6 @@ testBoth('Calling connect more than once', function(get, set) {
});
});

testBoth('Bindings should be inherited', function(get, set) {

var a = { foo: 'FOO', b: { bar: 'BAR' } };
var binding = new Binding('foo', 'b.bar');
var a2;

run(function () {
binding.connect(a);

a2 = create(a);
rewatch(a2);
});

equal(get(a2, 'foo'), "BAR", "Should have synced binding on child");
equal(get(a, 'foo'), "BAR", "Should NOT have synced binding on parent");

run(function () {
set(a2, 'b', { bar: 'BAZZ' });
});

equal(get(a2, 'foo'), "BAZZ", "Should have synced binding on child");
equal(get(a, 'foo'), "BAR", "Should NOT have synced binding on parent");

});

test('inherited bindings should sync on create', function() {
var a;
run(function () {
Expand Down
17 changes: 0 additions & 17 deletions packages/ember-metal/tests/utils/guidFor_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
guidFor
} from "ember-metal/utils";
import { rewatch } from "ember-metal/watching";

QUnit.module("guidFor");

Expand All @@ -27,22 +26,6 @@ test("Object", function() {
nanGuid( a );
});

test("Object with prototype", function() {
var Class = function() { };

guidFor(Class.prototype);

var a = new Class();
var b = new Class();

sameGuid( a, b , "without calling rewatch, objects copy the guid from their prototype");

rewatch(a);
rewatch(b);

diffGuid( a, b, "after calling rewatch, objects don't share guids" );
});

test("strings", function() {
var a = "string A";
var aprime = "string A";
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
meta,
makeArray
} from "ember-metal/utils";
import { rewatch } from "ember-metal/watching";
import { finishChains } from "ember-metal/chains";
import { sendEvent } from "ember-metal/events";
import {
Expand Down Expand Up @@ -196,7 +195,6 @@ function makeCtor() {
if (!wasApplied) {
wasApplied = true;
Class.PrototypeMixin.applyPartial(Class.prototype);
rewatch(Class.prototype);
}

return this.prototype;
Expand Down