language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | emberjs | ember.js | 6155d7898eed50cc7bc88fe9b6d06d73c5981411.json | Fix unsupported method errors in older browsers | packages/ember-runtime/lib/mixins/sortable.js | @@ -108,7 +108,7 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
var removedObjects = array.slice(idx, idx+removedCount);
var sortProperties = get(this, 'sortProperties');
- removedObjects.forEach(function(item) {
+ forEach(removedObjects, function(item) {
arrangedContent.removeObject(item);
forEach(sortProperties, function(sortProperty) {
@@ -128,7 +128,7 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
var addedObjects = array.slice(idx, idx+addedCount);
var arrangedContent = get(this, 'arrangedContent');
- addedObjects.forEach(function(item) {
+ forEach(addedObjects, function(item) {
this.insertItemSorted(item);
forEach(sortProperties, function(sortProperty) { | true |
Other | emberjs | ember.js | 6155d7898eed50cc7bc88fe9b6d06d73c5981411.json | Fix unsupported method errors in older browsers | packages/ember-states/lib/state_manager.js | @@ -1,4 +1,5 @@
var get = Ember.get, set = Ember.set, getPath = Ember.getPath, fmt = Ember.String.fmt;
+var arrayForEach = Ember.ArrayUtils.forEach;
require('ember-states/state');
@@ -602,7 +603,7 @@ Ember.StateManager = Ember.State.extend(
triggerSetupContext: function(root, segments) {
var state = root;
- Ember.ArrayUtils.forEach(segments, function(tuple) {
+ arrayForEach(segments, function(tuple) {
var path = tuple[0],
context = tuple[1];
@@ -629,11 +630,11 @@ Ember.StateManager = Ember.State.extend(
stateManager = this;
exitStates = exitStates.slice(0).reverse();
- exitStates.forEach(function(state) {
+ arrayForEach(exitStates, function(state) {
state.fire('exit', stateManager);
});
- enterStates.forEach(function(state) {
+ arrayForEach(enterStates, function(state) {
if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(state, 'path')); }
state.fire('enter', stateManager);
}); | true |
Other | emberjs | ember.js | a065d17ff04fc25e90927c3134a2a28cf32bbcfe.json | Remove unused variable | packages/ember-metal/lib/properties.js | @@ -13,7 +13,6 @@ var USE_ACCESSORS = Ember.USE_ACCESSORS,
GUID_KEY = Ember.GUID_KEY,
META_KEY = Ember.META_KEY,
meta = Ember.meta,
- o_create = Ember.create,
objectDefineProperty = Ember.platform.defineProperty,
SIMPLE_PROPERTY, WATCHED_PROPERTY;
| false |
Other | emberjs | ember.js | 25b38af12370c8be97cb75d19cb244ebaee0df85.json | Add Handlebars to benchmark runner | benchmarks/runner.js | @@ -15,6 +15,7 @@ function makeiframe(emberPath, suitePath, profile, callback) {
write("<title>" + name + "</title>");
write("<script src='../lib/jquery-1.7.2.js'></script>");
write("<script>ENV = {VIEW_PRESERVES_CONTEXT: true};</script>");
+ write("<script src='../lib/handlebars-1.0.0.beta.6.js'></script>");
write("<script src='" + emberPath + "'></script>");
write("<script src='benchmark.js'></script>");
write("<script src='iframe_runner.js'></script>"); | false |
Other | emberjs | ember.js | b2188911dafa60dabb6ba534acc5e044821a1bf5.json | Update each view benchmark | benchmarks/runner.js | @@ -14,6 +14,7 @@ function makeiframe(emberPath, suitePath, profile, callback) {
write("<title>" + name + "</title>");
write("<script src='../lib/jquery-1.7.2.js'></script>");
+ write("<script>ENV = {VIEW_PRESERVES_CONTEXT: true};</script>");
write("<script src='" + emberPath + "'></script>");
write("<script src='benchmark.js'></script>");
write("<script src='iframe_runner.js'></script>"); | true |
Other | emberjs | ember.js | b2188911dafa60dabb6ba534acc5e044821a1bf5.json | Update each view benchmark | benchmarks/suites/views/each_view.js | @@ -18,12 +18,12 @@ before(function() {
" </thead>" +
" <tbody>" +
" {{#each App.list}}" +
- ' {{#view Em.View contentBinding="this" tagName="tr"}}' +
- " <td>{{content.id}}</td>" +
- " <td>{{content.dateIn}}</td>" +
- " <td>{{content.tag}}</td>" +
- " <td>{{content.speed}}</td>" +
- " <td>{{content.length}}</td>" +
+ ' {{#view Em.View tagName="tr"}}' +
+ " <td>{{id}}</td>" +
+ " <td>{{dateIn}}</td>" +
+ " <td>{{tag}}</td>" +
+ " <td>{{speed}}</td>" +
+ " <td>{{length}}</td>" +
" {{/view}}" +
" {{/each}}" +
" </tbody>" + | true |
Other | emberjs | ember.js | 4f63e8d127ccbb2bda86a5cba7726218961097f6.json | Add options hash syntax to connectOutlet.
Also, if you explicitly set the `controller`
of the options hash to `null`, it will not set
a controller on the view, and it will be
inherited from the parent view. | packages/ember-views/lib/system/controller.js | @@ -75,15 +75,34 @@ Ember.ControllerMixin.reopen({
// outletName, viewClass
// viewClass, context
// outletName, viewClass, context
+ //
+ // Alternatively, an options hash may be passed:
+ //
+ // {
+ // name: 'outletName',
+ // view: App.ViewClass,
+ // context: {}
+ // }
+
+ var controller;
+
if (arguments.length === 2) {
if (Ember.Object.detect(outletName)) {
context = viewClass;
viewClass = outletName;
outletName = 'view';
}
} else if (arguments.length === 1) {
- viewClass = outletName;
- outletName = 'view';
+ if (Ember.typeOf(outletName) === 'object') {
+ var options = outletName;
+ outletName = options.name;
+ viewClass = options.view;
+ context = options.context;
+ controller = options.controller;
+ } else {
+ viewClass = outletName;
+ outletName = 'view';
+ }
}
var parts = viewClass.toString().split("."),
@@ -95,14 +114,19 @@ Ember.ControllerMixin.reopen({
var bareName = match[1], controllerName;
bareName = bareName.charAt(0).toLowerCase() + bareName.substr(1);
- controllerName = bareName + "Controller";
+ if (controller === undefined) {
+ controllerName = bareName + "Controller";
+ controller = get(get(this, 'controllers'), controllerName);
- var controller = get(get(this, 'controllers'), controllerName);
+ Ember.assert("You specified a context, but no " + controllerName + " was found", !context || !!controller);
+ } else if (controller === null) {
+ Ember.assert("You specified a context, but the controller passed to connectOutlet was null", !context || !!controller);
+ }
- Ember.assert("You specified a context, but no " + controllerName + " was found", !context || !!controller);
if (context) { controller.set('content', context); }
- var view = viewClass.create({ controller: controller });
+ var view = viewClass.create();
+ if (controller) { set(view, 'controller', controller); }
set(this, outletName, view);
return view; | true |
Other | emberjs | ember.js | 4f63e8d127ccbb2bda86a5cba7726218961097f6.json | Add options hash syntax to connectOutlet.
Also, if you explicitly set the `controller`
of the options hash to `null`, it will not set
a controller on the view, and it will be
inherited from the parent view. | packages/ember-views/tests/system/controller_test.js | @@ -10,7 +10,7 @@ module("Ember.Controller#connectOutlet", {
TestApp.ApplicationController = Ember.Controller.extend();
TestApp.PostController = Ember.Controller.extend();
- TestApp.PostView = Ember.Controller.extend();
+ TestApp.PostView = Ember.View.extend();
},
teardown: function() {
@@ -77,4 +77,50 @@ test("connectOutlet works if all three parameters are provided", function() {
equal(view.getPath('controller.content'), context, "the controller receives the context");
});
+test("connectOutlet works if a hash of options is passed", function() {
+ var postController = Ember.Controller.create(),
+ context = {};
+
+ var appController = TestApp.ApplicationController.create({
+ controllers: { postController: postController }
+ });
+
+ var view = appController.connectOutlet({
+ name: 'mainView',
+ view: TestApp.PostView,
+ context: context
+ });
+
+ ok(view instanceof TestApp.PostView, "the view is an instance of PostView");
+ equal(view.get('controller'), postController, "the controller is looked up on the parent's controllers hash");
+ equal(appController.get('mainView'), view, "the app controller's view is set");
+ equal(view.getPath('controller.content'), context, "the controller receives the context");
+});
+
+test("if the controller is explicitly set to null while connecting an outlet, the instantiated view will inherit its controller from its parent view", function() {
+ var postController = Ember.Controller.create(),
+ context = {};
+
+ var appController = TestApp.ApplicationController.create({
+ controllers: { postController: postController }
+ });
+
+ var view = appController.connectOutlet({
+ name: 'mainView',
+ view: TestApp.PostView,
+ controller: null
+ });
+
+ ok(view instanceof TestApp.PostView, "the view is an instance of PostView");
+ equal(view.get('controller'), null, "the controller is looked up on the parent's controllers hash");
+ equal(appController.get('mainView'), view, "the app controller's view is set");
+
+ var containerView = Ember.ContainerView.create({
+ controller: postController
+ });
+
+ containerView.get('childViews').pushObject(view);
+ equal(view.get('controller'), postController, "the controller was inherited from the parent");
+});
+
| true |
Other | emberjs | ember.js | 7049d29b8abab8f72117e6b99739cda97f7d59fb.json | Fix Ember.setPath when used on Ember.Namespaces | packages/ember-metal/lib/accessors.js | @@ -248,7 +248,7 @@ Ember.getPath = function(root, path) {
Ember.setPath = function(root, path, value, tolerant) {
var keyName;
- if (IS_GLOBAL.test(root)) {
+ if (typeof root === 'string' && IS_GLOBAL.test(root)) {
value = path;
path = root;
root = null; | true |
Other | emberjs | ember.js | 7049d29b8abab8f72117e6b99739cda97f7d59fb.json | Fix Ember.setPath when used on Ember.Namespaces | packages/ember-metal/tests/accessors/setPath_test.js | @@ -38,6 +38,13 @@ var obj, moduleOpts = {
module('Ember.setPath', moduleOpts);
+test('[Foo, bar] -> Foo.bar', function() {
+ window.Foo = {toString: function() { return 'Foo'; }}; // Behave like an Ember.Namespace
+ Ember.setPath(Foo, 'bar', 'baz');
+ equal(Ember.getPath(Foo, 'bar'), 'baz');
+ delete window.Foo;
+});
+
// ..........................................................
// LOCAL PATHS
// | true |
Other | emberjs | ember.js | 2ae680f7fc4ccb16478811c91d2eefabaa89b18e.json | Remove async transition docs. | packages/ember-states/lib/state.js | @@ -147,9 +147,6 @@ Ember.State = Ember.Object.extend(Ember.Evented,
@event
@param {Ember.StateManager} manager
- @param {Object} transition
- @param {Function} transition.async
- @param {Function} transition.resume
*/
enter: Ember.K,
@@ -158,9 +155,6 @@ Ember.State = Ember.Object.extend(Ember.Evented,
@event
@param {Ember.StateManager} manager
- @param {Object} transition
- @param {Function} transition.async
- @param {Function} transition.resume
*/
exit: Ember.K
}); | true |
Other | emberjs | ember.js | 2ae680f7fc4ccb16478811c91d2eefabaa89b18e.json | Remove async transition docs. | packages/ember-states/lib/state_manager.js | @@ -101,12 +101,12 @@ require('ember-states/state');
robotManager = Ember.StateManager.create({
initialState: 'poweredDown',
poweredDown: Ember.State.create({
- exit: function(stateManager, transition){
+ exit: function(stateManager){
console.log("exiting the poweredDown state")
}
}),
poweredUp: Ember.State.create({
- enter: function(stateManager, transition){
+ enter: function(stateManager){
console.log("entering the poweredUp state. Destroy all humans.")
}
})
@@ -126,12 +126,12 @@ require('ember-states/state');
robotManager = Ember.StateManager.create({
initialState: 'poweredDown',
poweredDown: Ember.State.create({
- exit: function(stateManager, transition){
+ exit: function(stateManager){
console.log("exiting the poweredDown state")
}
}),
poweredUp: Ember.State.create({
- enter: function(stateManager, transition){
+ enter: function(stateManager){
console.log("entering the poweredUp state. Destroy all humans.")
}
}) | true |
Other | emberjs | ember.js | 2ae680f7fc4ccb16478811c91d2eefabaa89b18e.json | Remove async transition docs. | packages/ember-viewstates/lib/view_state.js | @@ -137,10 +137,10 @@ var get = Ember.get, set = Ember.set;
viewStates = Ember.StateManager.create({
aState: Ember.ViewState.create({
view: Ember.View.extend({}),
- enter: function(manager, transition){
+ enter: function(manager){
// calling _super ensures this view will be
// properly inserted
- this._super(manager, transition);
+ this._super(manager);
// now you can do other things
} | true |
Other | emberjs | ember.js | b5ff0edb41f50e1f55446c14605fb566aa419ed4.json | Remove async transitions.
We suggest using transitional states instead. | packages/ember-states/lib/state_manager.js | @@ -350,24 +350,6 @@ require('ember-states/state');
robotManager.send('beginExtermination', allHumans)
robotManager.getPath('currentState.name') // 'rampaging'
- ## Async transitions
- When a state's `enter` and `exit` methods are called they passed a argument representing
- the transition. By calling `async()` and `resume()` on the transition object, the
- transition can be delayed. This can be useful to account for an animation between states.
-
- robotManager = Ember.StateManager.create({
- poweredUp: Ember.State.create({
- exit: function(stateManager, transition){
- console.log("beginning exit of the poweredUp state");
- transition.async();
- asyncStartShutdownDanceMoves().done(function(){
- console.log("completing exit of the poweredUp state");
- transition.resume();
- });
- }
- });
- });
-
**/
Ember.StateManager = Ember.State.extend(
/** @scope Ember.StateManager.prototype */ {
@@ -642,66 +624,41 @@ Ember.StateManager = Ember.State.extend(
}
},
- asyncEach: function(list, callback, doneCallback) {
- var async = false,
- self = this;
-
- if (!list.length) {
- if (doneCallback) { doneCallback.call(this); }
- return;
- }
-
- var head = list[0],
- tail = list.slice(1);
-
- var transition = {
- async: function() { async = true; },
- resume: function() {
- self.asyncEach(tail, callback, doneCallback);
- }
- };
-
- callback.call(this, head, transition);
-
- if (!async) { transition.resume(); }
- },
-
enterState: function(exitStates, enterStates, state) {
var log = this.enableLogging,
stateManager = this;
exitStates = exitStates.slice(0).reverse();
- this.asyncEach(exitStates, function(state, transition) {
- state.fire('exit', stateManager, transition);
- }, function() {
- this.asyncEach(enterStates, function(state, transition) {
- if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(state, 'path')); }
- state.fire('enter', stateManager, transition);
- }, function() {
- var startState = state,
- enteredState,
- initialState = get(startState, 'initialState');
-
- if (!initialState) {
- initialState = 'start';
- }
+ exitStates.forEach(function(state) {
+ state.fire('exit', stateManager);
+ });
- // right now, start states cannot be entered asynchronously
- while (startState = get(get(startState, 'states'), initialState)) {
- enteredState = startState;
+ enterStates.forEach(function(state) {
+ if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(state, 'path')); }
+ state.fire('enter', stateManager);
+ });
- if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(startState, 'path')); }
- startState.fire('enter', stateManager);
+ var startState = state,
+ enteredState,
+ initialState = get(startState, 'initialState');
- initialState = get(startState, 'initialState');
+ if (!initialState) {
+ initialState = 'start';
+ }
- if (!initialState) {
- initialState = 'start';
- }
- }
+ while (startState = get(get(startState, 'states'), initialState)) {
+ enteredState = startState;
- set(this, 'currentState', enteredState || state);
- });
- });
+ if (log) { Ember.Logger.log("STATEMANAGER: Entering " + get(startState, 'path')); }
+ startState.fire('enter', stateManager);
+
+ initialState = get(startState, 'initialState');
+
+ if (!initialState) {
+ initialState = 'start';
+ }
+ }
+
+ set(this, 'currentState', enteredState || state);
}
}); | true |
Other | emberjs | ember.js | b5ff0edb41f50e1f55446c14605fb566aa419ed4.json | Remove async transitions.
We suggest using transitional states instead. | packages/ember-states/tests/state_manager_test.js | @@ -105,44 +105,6 @@ test("it sends enter and exit events during state transitions", function() {
equal(loadedState.exited, 1, "sibling state should receive one exit event");
});
-test("a transition can be asynchronous", function() {
- expect(1);
-
- var counter = 0;
- var stateManager = Ember.StateManager.create({
- start: Ember.State.create({
- finish: function(manager) {
- manager.transitionTo('finished');
- },
-
- exit: function(manager, transition) {
- // pause QUnit while we test some async functionality
- stop();
-
- transition.async();
-
- setTimeout(function() {
- counter++;
- transition.resume();
- }, 50);
- }
- }),
-
- finished: Ember.State.create({
- enter: function() {
- equal(counter, 1, "increments counter and executes transition after specified timeout");
- start();
- },
-
- exit: function() {
- equal(arguments.length, 0, "does not pass transition object if arguments are empty");
- }
- })
- });
-
- stateManager.send('finish');
-});
-
test("it accepts absolute paths when changing states", function() {
var emptyState = loadedState.empty;
| true |
Other | emberjs | ember.js | b26ae897b4f8465171582807232f8113f458ecd6.json | Enumerate all properties per injection. | packages/ember-application/lib/system/application.js | @@ -125,8 +125,8 @@ Ember.Application = Ember.Namespace.extend(
Ember.runLoadHooks('application', this);
- properties.forEach(function(property) {
- injections.forEach(function(injection) {
+ injections.forEach(function(injection) {
+ properties.forEach(function(property) {
injection[1](namespace, router, property);
});
}); | true |
Other | emberjs | ember.js | b26ae897b4f8465171582807232f8113f458ecd6.json | Enumerate all properties per injection. | packages/ember-application/tests/system/application_test.js | @@ -205,22 +205,25 @@ test("initialize application with stateManager via initialize call from Router c
});
test("injections can be registered in a specified order", function() {
+
var oldInjections = Ember.Application.injections;
- var firstInjectionCalled;
+ var firstInjectionCalled = 0,
+ secondInjectionCalled = 0;
Ember.Application.injections = Ember.A();
Ember.Application.registerInjection({
name: 'second',
injection: function() {
- ok(firstInjectionCalled, 'first injection should be called first');
- firstInjectionCalled = false;
+ ok(firstInjectionCalled > 0, 'first injection should be called first');
+ secondInjectionCalled++;
}
});
Ember.Application.registerInjection({
name: 'first',
injection: function() {
- firstInjectionCalled = true;
+ firstInjectionCalled++;
+ ok(secondInjectionCalled === 0, "second injection should not have been called yet");
},
before: 'second'
});
@@ -230,6 +233,7 @@ test("injections can be registered in a specified order", function() {
app = Ember.Application.create({
rootElement: '#qunit-fixture'
});
+ expect(get(Ember.keys(app), 'length') * 2);
router = Ember.Object.create();
app.initialize(router); | true |
Other | emberjs | ember.js | 627d214428191b7bcd2a8ad23aa5d048d9e6734c.json | Improve invalidation of view's controller prop
A view's controller is inherited from its parent
unless specifically overridden. This commit
improves the invalidation of the cached
computed property when:
a) the parent view changes, or
b) the controller of the parent changes. | packages/ember-views/lib/views/view.js | @@ -501,7 +501,6 @@ Ember.View = Ember.Object.extend(Ember.Evented,
return value;
} else {
parentView = get(this, 'parentView');
-
return parentView ? get(parentView, 'controller') : null;
}
}).property().cacheable(),
@@ -756,8 +755,20 @@ Ember.View = Ember.Object.extend(Ember.Evented,
view.propertyDidChange('itemView');
view.propertyDidChange('contentView');
});
+
+ if (getPath(this, 'parentView.controller') && !get(this, 'controller')) {
+ this.notifyPropertyChange('controller');
+ }
}, '_parentView'),
+ _controllerDidChange: Ember.observer(function() {
+ if (this.isDestroying) { return; }
+
+ this.forEachChildView(function(view) {
+ view.propertyDidChange('controller');
+ });
+ }, 'controller'),
+
cloneKeywords: function() {
var templateData = get(this, 'templateData');
| true |
Other | emberjs | ember.js | 627d214428191b7bcd2a8ad23aa5d048d9e6734c.json | Improve invalidation of view's controller prop
A view's controller is inherited from its parent
unless specifically overridden. This commit
improves the invalidation of the cached
computed property when:
a) the parent view changes, or
b) the controller of the parent changes. | packages/ember-views/tests/views/view/controller_test.js | @@ -0,0 +1,33 @@
+module("Ember.View - controller property");
+
+test("controller property should be inherited from nearest ancestor with controller", function() {
+ var grandparent = Ember.ContainerView.create();
+ var parent = Ember.ContainerView.create();
+ var child = Ember.ContainerView.create();
+ var grandchild = Ember.ContainerView.create();
+
+ var grandparentController = {};
+ var parentController = {};
+
+ Ember.run(function() {
+ grandparent.set('controller', grandparentController);
+ parent.set('controller', parentController);
+
+ grandparent.get('childViews').pushObject(parent);
+ parent.get('childViews').pushObject(child);
+
+ strictEqual(grandparent.get('controller'), grandparentController);
+ strictEqual(parent.get('controller'), parentController);
+ strictEqual(child.get('controller'), parentController);
+ strictEqual(grandchild.get('controller'), null);
+
+ child.get('childViews').pushObject(grandchild);
+ strictEqual(grandchild.get('controller'), parentController);
+
+ var newController = {};
+ parent.set('controller', newController);
+ strictEqual(parent.get('controller'), newController);
+ strictEqual(child.get('controller'), newController);
+ strictEqual(grandchild.get('controller'), newController);
+ });
+}); | true |
Other | emberjs | ember.js | 96791e2173b12b5730d1840b5946d09a5558da8a.json | Fix failing test | packages/ember-handlebars/tests/helpers/with_test.js | @@ -82,21 +82,22 @@ test("it should support #with Foo.bar as qux", function() {
equal(view.$().text(), "updated", "should update");
});
-module("Handlebars {{#with this as foo}}");
+if (Ember.VIEW_PRESERVES_CONTEXT) {
+ module("Handlebars {{#with this as foo}}");
-test("it should support #with this as qux", function() {
- var view = Ember.View.create({
- template: Ember.Handlebars.compile("{{#with this as person}}{{person.name}}{{/with}}"),
- controller: Ember.Object.create({ name: "Los Pivots" })
- });
-
- appendView(view);
- equal(view.$().text(), "Los Pivots", "should be properly scoped");
+ test("it should support #with this as qux", function() {
+ var view = Ember.View.create({
+ template: Ember.Handlebars.compile("{{#with this as person}}{{person.name}}{{/with}}"),
+ controller: Ember.Object.create({ name: "Los Pivots" })
+ });
- Ember.run(function() {
- Ember.setPath(view, 'controller.name', "l'Pivots");
- });
+ appendView(view);
+ equal(view.$().text(), "Los Pivots", "should be properly scoped");
- equal(view.$().text(), "l'Pivots", "should update");
-});
+ Ember.run(function() {
+ Ember.setPath(view, 'controller.name', "l'Pivots");
+ });
+ equal(view.$().text(), "l'Pivots", "should update");
+ });
+} | false |
Other | emberjs | ember.js | 7a65598b71b66bf430d5f9937e8e1d80089ae449.json | Fix documentation for adding view to ContainerView
View B will still exist in container view after pushObject. | packages/ember-views/lib/views/container_view.js | @@ -122,12 +122,13 @@ var childViewsProperty = Ember.computed(function() {
aContainer.get('childViews') // [aContainer.aView, aContainer.bView]
aContainer.get('childViews').pushObject(AnotherViewClass.create())
- aContainer.get('childViews') // [aContainer.aView, <AnotherViewClass instance>]
+ aContainer.get('childViews') // [aContainer.aView, aContainer.bView, <AnotherViewClass instance>]
Will result in the following HTML
<div class="ember-view the-container">
<div class="ember-view">A</div>
+ <div class="ember-view">B</div>
<div class="ember-view">Another view</div>
</div>
| false |
Other | emberjs | ember.js | 9ef59af7269fdea81be06eb51fbf2e640a39e67c.json | Use accessors for eventTransitions | packages/ember-states/lib/state.js | @@ -55,7 +55,7 @@ Ember.State = Ember.Object.extend(Ember.Evented,
init: function() {
var states = get(this, 'states'), foundStates;
set(this, 'childStates', Ember.A());
- this.eventTransitions = this.eventTransitions || {};
+ set(this, 'eventTransitions', get(this, 'eventTransitions') || {});
var name, value, transitionTarget;
| false |
Other | emberjs | ember.js | 136455596cd02a2b543732f620302cbfd7ee3117.json | Finish implementation of Sortable mixin
This borrows heavily from tchak's implementation
;) | packages/ember-runtime/lib/mixins/sortable.js | @@ -1,79 +1,180 @@
-var get = Ember.get;
+var get = Ember.get, set = Ember.set, forEach = Ember.ArrayUtils.forEach;
-Ember.SortableMixin = Ember.Mixin.create({
- arrangedContent: Ember.computed('content', 'orderBy', function(key, value) {
+Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
+ sortProperties: null,
+ sortAscending: true,
+
+ addObject: function(obj) {
+ var content = get(this, 'content');
+ content.pushObject(obj);
+ },
+
+ removeObject: function(obj) {
+ var content = get(this, 'content');
+ content.removeObject(obj);
+ },
+
+ orderBy: function(item1, item2) {
+ var result = 0,
+ sortProperties = get(this, 'sortProperties'),
+ sortAscending = get(this, 'sortAscending');
+
+ Ember.assert("you need to define `sortProperties`", !!sortProperties);
+
+ forEach(sortProperties, function(propertyName) {
+ if (result === 0) {
+ result = Ember.compare(get(item1, propertyName), get(item2, propertyName));
+ if ((result !== 0) && !sortAscending) {
+ result = (-1) * result;
+ }
+ }
+ });
+
+ return result;
+ },
+
+ destroy: function() {
var content = get(this, 'content'),
- orderBy = get(this, 'orderBy');
+ sortProperties = get(this, 'sortProperties');
- if (orderBy) {
- content = content.slice();
- content.sort(function(a, b) {
- var aValue, bValue;
+ if (content && sortProperties) {
+ forEach(content, function(item) {
+ forEach(sortProperties, function(sortProperty) {
+ Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
+ }, this);
+ }
- aValue = a ? get(a, orderBy) : undefined;
- bValue = b ? get(b, orderBy) : undefined;
+ return this._super();
+ },
- if (aValue < bValue) { return -1; }
- if (aValue > bValue) { return 1; }
+ isSorted: Ember.computed('sortProperties', function() {
+ return !!get(this, 'sortProperties');
+ }),
- return 0;
- });
+ arrangedContent: Ember.computed('content', 'sortProperties.@each', function(key, value) {
+ var content = get(this, 'content'),
+ isSorted = get(this, 'isSorted'),
+ sortProperties = get(this, 'sortProperties'),
+ self = this;
+ if (content && isSorted) {
+ content = content.slice();
+ content.sort(function(item1, item2) {
+ return self.orderBy(item1, item2);
+ });
+ forEach(content, function(item) {
+ forEach(sortProperties, function(sortProperty) {
+ Ember.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
+ }, this);
return Ember.A(content);
}
return content;
}).cacheable(),
+ _contentWillChange: Ember.beforeObserver(function() {
+ var content = get(this, 'content'),
+ sortProperties = get(this, 'sortProperties');
+
+ if (content && sortProperties) {
+ forEach(content, function(item) {
+ forEach(sortProperties, function(sortProperty) {
+ Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
+ }, this);
+ }
+
+ this._super();
+ }, 'content'),
+
+ sortAscendingWillChange: Ember.beforeObserver(function() {
+ this._lastSortAscending = get(this, 'sortAscending');
+ }, 'sortAscending'),
+
+ sortAscendingDidChange: Ember.observer(function() {
+ if (get(this, 'sortAscending') !== this._lastSortAscending) {
+ var arrangedContent = get(this, 'arrangedContent');
+ arrangedContent.reverse();
+ }
+ }, 'sortAscending'),
+
contentArrayWillChange: function(array, idx, removedCount, addedCount) {
- var orderBy = get(this, 'orderBy');
+ var isSorted = get(this, 'isSorted');
- if (orderBy) {
+ if (isSorted) {
var arrangedContent = get(this, 'arrangedContent');
var removedObjects = array.slice(idx, idx+removedCount);
+ var sortProperties = get(this, 'sortProperties');
removedObjects.forEach(function(item) {
arrangedContent.removeObject(item);
+
+ forEach(sortProperties, function(sortProperty) {
+ Ember.removeObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
});
}
return this._super(array, idx, removedCount, addedCount);
},
contentArrayDidChange: function(array, idx, removedCount, addedCount) {
- var orderBy = get(this, 'orderBy');
+ var isSorted = get(this, 'isSorted'),
+ sortProperties = get(this, 'sortProperties');
- if (orderBy) {
+ if (isSorted) {
var addedObjects = array.slice(idx, idx+addedCount);
var arrangedContent = get(this, 'arrangedContent');
- var length = arrangedContent.get('length');
- addedObjects.forEach(function(object) {
- idx = this._binarySearch(get(object, orderBy), orderBy, 0, length);
- arrangedContent.insertAt(idx, object);
- object.addObserver(orderBy, this, 'contentItemOrderByDidChange');
- length++;
+ addedObjects.forEach(function(item) {
+ this.insertItemSorted(item);
+
+ forEach(sortProperties, function(sortProperty) {
+ Ember.addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
this.arrayContentDidChange(idx, 0, 1);
}, this);
}
return this._super(array, idx, removedCount, addedCount);
},
- _binarySearch: function(value, orderBy, low, high) {
- var mid, midValue;
+ insertItemSorted: function(item) {
+ var arrangedContent = get(this, 'arrangedContent');
+ var length = get(arrangedContent, 'length');
+
+ var idx = this._binarySearch(item, 0, length);
+ arrangedContent.insertAt(idx, item);
+ },
+
+ contentItemSortPropertyDidChange: function(item) {
+ var arrangedContent = get(this, 'arrangedContent'),
+ index = arrangedContent.indexOf(item);
+
+ arrangedContent.removeObject(item);
+ this.insertItemSorted(item);
+ },
+
+ _binarySearch: function(item, low, high) {
+ var mid, midItem, res, arrangedContent;
if (low === high) {
return low;
}
+ arrangedContent = get(this, 'arrangedContent');
+
mid = low + Math.floor((high - low) / 2);
- midValue = get(this.objectAt(mid), orderBy);
+ midItem = arrangedContent.objectAt(mid);
+
+ res = this.orderBy(midItem, item);
- if (value > midValue) {
- return this._binarySearch(value, orderBy, mid+1, high);
- } else if (value < midValue) {
- return this._binarySearch(value, orderBy, low, mid);
+ if (res < 0) {
+ return this._binarySearch(item, mid+1, high);
+ } else if (res > 0) {
+ return this._binarySearch(item, low, mid);
}
return mid; | false |
Other | emberjs | ember.js | a2ec6252434c16599407ac91311611b8ee7a1e4f.json | Remove trailing whitespace | lib/github_uploader.rb | @@ -16,7 +16,7 @@ def authorized?
end
def token_path
- File.expand_path(".github-upload-token", @root)
+ File.expand_path(".github-upload-token", @root)
end
def check_token | false |
Other | emberjs | ember.js | d6ee63b3af87e10b56d88c28ed82a1f64f58cd56.json | Remove unused code. | packages/ember-handlebars/tests/views/collection_view_test.js | @@ -105,7 +105,6 @@ test("should be able to specify which class should be used for the empty view",
window.App = Ember.Application.create();
});
- App.ListView = Ember.CollectionView.extend();
App.EmptyView = Ember.View.extend({
template: Ember.Handlebars.compile('This is an empty view')
}); | false |
Other | emberjs | ember.js | 96768564fcd17e36d367a79e9f2eca076a4d37eb.json | Support #each foo in this and #with this as bar | packages/ember-handlebars/lib/helpers/binding.js | @@ -174,7 +174,10 @@ EmberHandlebars.registerHelper('with', function(context, options) {
// together. When we implement that functionality, we should use it here.
var contextKey = Ember.$.expando + Ember.guidFor(this);
options.data.keywords[contextKey] = this;
- Ember.bind(options.data.keywords, keywordName, contextKey + '.' + path);
+
+ // if the path is '' ("this"), just bind directly to the current context
+ var contextPath = path ? contextKey + '.' + path : contextKey;
+ Ember.bind(options.data.keywords, keywordName, contextPath);
}
return bind.call(this, path, options.fn, true, function(result) { | true |
Other | emberjs | ember.js | 96768564fcd17e36d367a79e9f2eca076a4d37eb.json | Support #each foo in this and #with this as bar | packages/ember-handlebars/lib/helpers/each.js | @@ -42,6 +42,7 @@ Ember.Handlebars.registerHelper('each', function(path, options) {
options = arguments[3];
path = arguments[2];
+ if (path === '') { path = "this"; }
options.hash.keyword = keywordName;
} else { | true |
Other | emberjs | ember.js | 96768564fcd17e36d367a79e9f2eca076a4d37eb.json | Support #each foo in this and #with this as bar | packages/ember-handlebars/tests/helpers/each_test.js | @@ -179,4 +179,16 @@ if (Ember.VIEW_PRESERVES_CONTEXT) {
equal(view.$().text(), "My Cool Each Test 1My Cool Each Test 2");
});
+ test("#each accepts 'this' as the right hand side", function() {
+ view = Ember.View.create({
+ template: templateFor("{{#each item in this}}{{view.title}} {{item.name}}{{/each}}"),
+ title: "My Cool Each Test",
+ controller: Ember.A([{ name: 1 }, { name: 2 }])
+ });
+
+ append(view);
+
+ equal(view.$().text(), "My Cool Each Test 1My Cool Each Test 2");
+ });
+
} | true |
Other | emberjs | ember.js | 96768564fcd17e36d367a79e9f2eca076a4d37eb.json | Support #each foo in this and #with this as bar | packages/ember-handlebars/tests/helpers/with_test.js | @@ -81,3 +81,22 @@ test("it should support #with Foo.bar as qux", function() {
equal(view.$().text(), "updated", "should update");
});
+
+module("Handlebars {{#with this as foo}}");
+
+test("it should support #with this as qux", function() {
+ var view = Ember.View.create({
+ template: Ember.Handlebars.compile("{{#with this as person}}{{person.name}}{{/with}}"),
+ controller: Ember.Object.create({ name: "Los Pivots" })
+ });
+
+ appendView(view);
+ equal(view.$().text(), "Los Pivots", "should be properly scoped");
+
+ Ember.run(function() {
+ Ember.setPath(view, 'controller.name', "l'Pivots");
+ });
+
+ equal(view.$().text(), "l'Pivots", "should update");
+});
+ | true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-states/lib/state_manager.js | @@ -149,7 +149,7 @@ require('ember-states/state');
Each state property may itself contain properties that are instances of Ember.State.
- The StateManager can transition to specific sub-states in a series of goToState method calls or
+ The StateManager can transition to specific sub-states in a series of transitionTo method calls or
via a single transitionTo with the full path to the specific state. The StateManager will also
keep track of the full path to its currentState
| true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-states/tests/routable_test.js | @@ -18,7 +18,7 @@ test("it should have its updateRoute method called when it is entered", function
location: locationStub,
root: Ember.State.create({
ready: function(manager) {
- manager.goToState('initial');
+ manager.transitionTo('initial');
},
initial: state
@@ -41,7 +41,7 @@ test("when you call `route` on the Router, it calls it on the current state", fu
location: locationStub,
root: Ember.State.create({
ready: function(manager) {
- manager.goToState('initial');
+ manager.transitionTo('initial');
},
initial: state | true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-states/tests/state_manager_test.js | @@ -70,15 +70,15 @@ test("it discovers states that are properties of the state manager", function()
test("it reports its current state", function() {
ok(get(stateManager, 'currentState') === null, "currentState defaults to null if no state is specified");
- stateManager.goToState('loadingState');
- ok(get(stateManager, 'currentState') === loadingState, "currentState changes after goToState() is called");
+ stateManager.transitionTo('loadingState');
+ ok(get(stateManager, 'currentState') === loadingState, "currentState changes after transitionTo() is called");
- stateManager.goToState('loadedState');
+ stateManager.transitionTo('loadedState');
ok(get(stateManager, 'currentState') === loadedState, "currentState can change to a sibling state");
});
test("it sends enter and exit events during state transitions", function() {
- stateManager.goToState('loadingState');
+ stateManager.transitionTo('loadingState');
equal(loadingState.entered, 1, "state should receive one enter event");
equal(loadingState.exited, 0, "state should not have received an exit event");
@@ -88,7 +88,7 @@ test("it sends enter and exit events during state transitions", function() {
loadingState.reset();
loadedState.reset();
- stateManager.goToState('loadedState');
+ stateManager.transitionTo('loadedState');
equal(loadingState.entered, 0, "state should not receive an enter event");
equal(loadingState.exited, 1, "state should receive one exit event");
equal(loadedState.entered, 1, "sibling state should receive one enter event");
@@ -97,7 +97,7 @@ test("it sends enter and exit events during state transitions", function() {
loadingState.reset();
loadedState.reset();
- stateManager.goToState('loadingState');
+ stateManager.transitionTo('loadingState');
equal(loadingState.entered, 1, "state should receive one enter event");
equal(loadingState.exited, 0, "state should not have received an exit event");
@@ -112,7 +112,7 @@ test("a transition can be asynchronous", function() {
var stateManager = Ember.StateManager.create({
start: Ember.State.create({
finish: function(manager) {
- manager.goToState('finished');
+ manager.transitionTo('finished');
},
exit: function(manager, transition) {
@@ -146,25 +146,25 @@ test("a transition can be asynchronous", function() {
test("it accepts absolute paths when changing states", function() {
var emptyState = loadedState.empty;
- stateManager.goToState('loadingState');
+ stateManager.transitionTo('loadingState');
- stateManager.goToState('loadedState.empty');
+ stateManager.transitionTo('loadedState.empty');
equal(emptyState.entered, 1, "sends enter event to substate");
equal(emptyState.exited, 0, "does not send exit event to substate");
ok(stateManager.get('currentState') === emptyState, "updates currentState property to state at absolute path");
});
-test("it does not enter an infinite loop in goToState", function() {
+test("it does not enter an infinite loop in transitionTo", function() {
var emptyState = loadedState.empty;
- stateManager.goToState('loadedState.empty');
+ stateManager.transitionTo('loadedState.empty');
- stateManager.goToState('');
- ok(stateManager.get('currentState') === emptyState, "goToState does nothing when given empty name");
+ stateManager.transitionTo('');
+ ok(stateManager.get('currentState') === emptyState, "transitionTo does nothing when given empty name");
- stateManager.goToState('nonexistentState');
- ok(stateManager.get('currentState') === emptyState, "goToState does not infinite loop when given nonexistent State");
+ stateManager.transitionTo('nonexistentState');
+ ok(stateManager.get('currentState') === emptyState, "transitionTo does not infinite loop when given nonexistent State");
});
test("it automatically transitions to a default state", function() {
@@ -188,7 +188,7 @@ test("it automatically transitions to a default state that is an instance", func
}
});
- stateManager.goToState('foo');
+ stateManager.transitionTo('foo');
ok(get(stateManager, 'currentState').isStart, "automatically transitions to start state");
});
@@ -287,15 +287,15 @@ test("it sends exit events to nested states when changing to a top-level state",
})
});
- stateManager.goToState('login');
+ stateManager.transitionTo('login');
equal(stateManager.login.entered, 1, "precond - it enters the login state");
equal(stateManager.login.start.entered, 1, "automatically enters the start state");
ok(stateManager.get('currentState') === stateManager.login.start, "automatically sets currentState to start state");
stateManager.login.reset();
stateManager.login.start.reset();
- stateManager.goToState('redeem');
+ stateManager.transitionTo('redeem');
equal(stateManager.login.exited, 1, "login state is exited once");
equal(stateManager.login.start.exited, 1, "start state is exited once");
@@ -316,8 +316,8 @@ test("it sends exit events in the correct order when changing to a top-level sta
})
});
- stateManager.goToState('start.outer.inner');
- stateManager.goToState('start');
+ stateManager.transitionTo('start.outer.inner');
+ stateManager.transitionTo('start');
equal(exitOrder.length, 2, "precond - it calls both exits");
equal(exitOrder[0], 'exitedInner', "inner exit is called first");
equal(exitOrder[1], 'exitedOuter', "outer exit is called second");
@@ -336,11 +336,11 @@ test("it sends exit events in the correct order when changing to a state multipl
})
});
- stateManager.goToState('start.outer.inner');
- stateManager.goToState('start');
- stateManager.goToState('start.outer.inner');
+ stateManager.transitionTo('start.outer.inner');
+ stateManager.transitionTo('start');
+ stateManager.transitionTo('start.outer.inner');
exitOrder = [];
- stateManager.goToState('start');
+ stateManager.transitionTo('start');
equal(exitOrder.length, 2, "precond - it calls both exits");
equal(exitOrder[0], 'exitedInner', "inner exit is called first");
equal(exitOrder[1], 'exitedOuter', "outer exit is called second");
@@ -376,7 +376,7 @@ module("Ember.StateManager - Event Dispatching", {
})
});
- stateManager.goToState('loading');
+ stateManager.transitionTo('loading');
}
});
@@ -387,14 +387,14 @@ test("it dispatches events to the current state", function() {
});
test("it dispatches events to a parent state if the child state does not respond to it", function() {
- stateManager.goToState('loaded.empty');
+ stateManager.transitionTo('loaded.empty');
stateManager.send('anEvent');
equal(loadedEventCalled, 1, "parent state receives event");
});
test("it does not dispatch events to parents if the child responds to it", function() {
- stateManager.goToState('loaded.empty');
+ stateManager.transitionTo('loaded.empty');
stateManager.send('eventInChild');
equal(eventInChildCalled, 1, "does not dispatch event to parent");
@@ -438,13 +438,13 @@ module("Ember.Statemanager - Pivot states", {
}
});
-test("goToState triggers all enter states", function() {
- stateManager.goToState('grandparent.parent.child');
+test("transitionTo triggers all enter states", function() {
+ stateManager.transitionTo('grandparent.parent.child');
equal(stateManager.grandparent.entered, 1, "the top level should be entered");
equal(stateManager.grandparent.parent.entered, 1, "intermediate states should be entered");
equal(stateManager.grandparent.parent.child.entered, 1, "the final state should be entered");
- stateManager.goToState('grandparent.parent.sibling');
+ stateManager.transitionTo('grandparent.parent.sibling');
equal(stateManager.grandparent.entered, 1, "the top level should not be re-entered");
equal(stateManager.grandparent.parent.entered, 1, "intermediate states should not be re-entered");
equal(stateManager.grandparent.parent.child.entered, 1, "the final state should not be re-entered");
@@ -454,9 +454,9 @@ test("goToState triggers all enter states", function() {
equal(stateManager.grandparent.parent.exited, 0, "intermediate states should not have exited");
});
-test("goToState with current state does not trigger enter or exit", function() {
- stateManager.goToState('grandparent.parent.child');
- stateManager.goToState('grandparent.parent.child');
+test("transitionTo with current state does not trigger enter or exit", function() {
+ stateManager.transitionTo('grandparent.parent.child');
+ stateManager.transitionTo('grandparent.parent.child');
equal(stateManager.grandparent.entered, 1, "the top level should only be entered once");
equal(stateManager.grandparent.parent.entered, 1, "intermediate states should only be entered once");
equal(stateManager.grandparent.parent.child.entered, 1, "the final state should only be entered once");
@@ -473,7 +473,7 @@ test("if a context is passed to a transition, the state's setup event is trigger
stateManager = Ember.StateManager.create({
start: Ember.State.create({
goNext: function(manager, context) {
- manager.goToState('next', context);
+ manager.transitionTo('next', context);
}
}),
@@ -497,15 +497,15 @@ test("if a context is passed to a transition and the path is to the current stat
start: Ember.State.create({
goNext: function(manager, context) {
counter++;
- manager.goToState('foo.next', counter);
+ manager.transitionTo('foo.next', counter);
}
}),
foo: Ember.State.create({
next: Ember.State.create({
goNext: function(manager, context) {
counter++;
- manager.goToState('next', counter);
+ manager.transitionTo('next', counter);
},
setup: function(manager, context) {
@@ -556,7 +556,7 @@ test("multiple contexts can be provided in a single transitionTo", function() {
stateManager = Ember.StateManager.create({
start: Ember.State.create({
goNuts: function(manager, context) {
- manager.goToState('foo.next', context);
+ manager.transitionTo('foo.next', context);
}
}),
| true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-states/tests/state_test.js | @@ -133,10 +133,10 @@ test("states set up proper names on their children", function() {
}
});
- manager.goToState('first');
+ manager.transitionTo('first');
equal(getPath(manager, 'currentState.path'), 'first');
- manager.goToState('first.insideFirst');
+ manager.transitionTo('first.insideFirst');
equal(getPath(manager, 'currentState.path'), 'first.insideFirst');
});
@@ -151,10 +151,10 @@ test("states with child instances set up proper names on their children", functi
}
});
- manager.goToState('first');
+ manager.transitionTo('first');
equal(getPath(manager, 'currentState.path'), 'first');
- manager.goToState('first.insideFirst');
+ manager.transitionTo('first.insideFirst');
equal(getPath(manager, 'currentState.path'), 'first.insideFirst');
});
| true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-viewstates/lib/view_state.js | @@ -61,7 +61,7 @@ var get = Ember.get, set = Ember.set;
})
})
- viewStates.goToState('showingPeople')
+ viewStates.transitionTo('showingPeople')
The above code will change the rendered HTML from
@@ -75,10 +75,10 @@ var get = Ember.get, set = Ember.set;
</div>
</body>
- Changing the current state via `goToState` from `showingPeople` to
+ Changing the current state via `transitionTo` from `showingPeople` to
`showingPhotos` will remove the `showingPeople` view and add the `showingPhotos` view:
- viewStates.goToState('showingPhotos')
+ viewStates.transitionTo('showingPhotos')
will change the rendered HTML to
@@ -114,7 +114,7 @@ var get = Ember.get, set = Ember.set;
})
- viewStates.goToState('showingPeople.withEditingPanel')
+ viewStates.transitionTo('showingPeople.withEditingPanel')
Will result in the following rendered HTML: | true |
Other | emberjs | ember.js | 03c94f8278d8cbdb6621051f2ac2e9f61e2eb36f.json | Replace occurances of goToState with transitionTo. | packages/ember-viewstates/tests/view_state_test.js | @@ -87,7 +87,7 @@ test("it appends and removes a view when it is entered and exited", function() {
equal(Ember.$('#test-view').length, 1, "found view with custom id in DOM");
Ember.run(function() {
- stateManager.goToState('other');
+ stateManager.transitionTo('other');
});
equal(Ember.$('#test-view').length, 0, "can't find view with custom id in DOM");
@@ -121,7 +121,7 @@ test("it appends and removes a view to the element specified in its state manage
equal(Ember.$("#test-view").parent().attr('id'), "my-container", "appends view to the correct element");
Ember.run(function() {
- stateManager.goToState('other');
+ stateManager.transitionTo('other');
});
equal(Ember.$('#test-view').length, 0, "can't find view with custom id in DOM");
@@ -172,19 +172,19 @@ test("it appends and removes a view to the view specified in the state manager's
equal(get(rootView, 'childViews').objectAt(0), view, "the view added is the view state's view");
Ember.run(function() {
- stateManager.goToState('other');
+ stateManager.transitionTo('other');
});
equal(getPath(rootView, 'childViews.length'), 0, "transitioning to a state without a view should remove the previous view");
Ember.run(function() {
- stateManager.goToState('otherWithView');
+ stateManager.transitionTo('otherWithView');
});
equal(get(rootView, 'childViews').objectAt(0), otherView, "the view added is the otherView state's view");
Ember.run(function() {
- stateManager.goToState('start');
+ stateManager.transitionTo('start');
});
equal(getPath(rootView, 'childViews.length'), 1, "when transitioning into a view state, its view should be added as a child of the root view");
equal(get(rootView, 'childViews').objectAt(0), view, "the view added is the view state's view");
@@ -201,7 +201,7 @@ test("it reports the view associated with the current view state, if any", funct
});
Ember.run(function(){
- stateManager.goToState('foo.bar');
+ stateManager.transitionTo('foo.bar');
});
equal(get(stateManager, 'currentView'), view, "returns nearest parent view state's view"); | true |
Other | emberjs | ember.js | b6c1c2fffa2e535da8e1eb7babaa6119ff58b731.json | Use Ember.assert instead of throw | packages/ember-metal/lib/mixin.js | @@ -76,7 +76,7 @@ function mergeMixins(mixins, m, descs, values, base) {
for(idx=0;idx<len;idx++) {
mixin = mixins[idx];
- if (!mixin) throw new Error('Null value found in Ember.mixin()');
+ Ember.assert('Null value found in Ember.mixin()', !!mixin);
if (mixin instanceof Mixin) {
guid = Ember.guidFor(mixin);
@@ -224,7 +224,7 @@ function applyMixin(obj, mixins, partial) {
if (desc === REQUIRED) {
if (!(key in obj)) {
- if (!partial) throw new Error('Required property not defined: '+key);
+ Ember.assert('Required property not defined: '+key, !!partial);
// for partial applies add to hash of required keys
req = writableReq(obj);
@@ -311,7 +311,8 @@ function applyMixin(obj, mixins, partial) {
if (META_SKIP[key]) continue;
keys.push(key);
}
- throw new Error('Required properties not defined: '+keys.join(','));
+ // TODO: Remove surrounding if clause from production build
+ Ember.assert('Required properties not defined: '+keys.join(','));
}
return obj;
} | false |
Other | emberjs | ember.js | c5e39622b5799d03b5ae8e7a73415e1210d920eb.json | Remove unused local variables | packages/ember-metal/lib/computed.js | @@ -127,7 +127,7 @@ function mkCpSetter(keyName, desc) {
return function(value) {
var m = meta(this, cacheable),
watched = (m.source===this) && m.watching[keyName]>0,
- ret, oldSuspended, lastSetValues;
+ ret, oldSuspended;
oldSuspended = desc._suspended;
desc._suspended = this;
@@ -293,7 +293,7 @@ Cp.set = function(obj, keyName, value) {
var m = meta(obj, cacheable),
watched = (m.source===obj) && m.watching[keyName]>0,
- ret, oldSuspended, lastSetValues;
+ ret, oldSuspended;
oldSuspended = this._suspended;
this._suspended = obj; | false |
Other | emberjs | ember.js | 7d15e7d99cab555bf6c86d56b6bb30f5c57280e7.json | Remove unused argument to oneWay | packages/ember-metal/lib/binding.js | @@ -106,13 +106,9 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
means that if you change the "to" side directly, the "from" side may have
a different value.
- @param {Boolean} flag
- (Optional) passing nothing here will make the binding oneWay. You can
- instead pass false to disable oneWay, making the binding two way again.
-
@returns {Ember.Binding} receiver
*/
- oneWay: function(flag) {
+ oneWay: function() {
this._oneWay = true;
return this;
}, | false |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | Rakefile | @@ -116,6 +116,7 @@ task :test, [:suite] => :dist do |t, args|
suites = {
:default => packages.map{|p| "package=#{p}" },
+ :runtime => [ "package=ember-metal,ember-runtime" ],
# testing older jQuery 1.6.4 for compatibility
:all => packages.map{|p| "package=#{p}" } +
["package=all&jquery=1.6.4&nojshint=true", | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-handlebars/lib/ext.js | @@ -7,6 +7,8 @@
require("ember-views/system/render_buffer");
+var objectCreate = Ember.create;
+
/**
@namespace
@name Handlebars
@@ -34,19 +36,19 @@ Ember.assert("Ember Handlebars requires Handlebars 1.0.beta.5 or greater", windo
To create an Ember.Handlebars template, call Ember.Handlebars.compile(). This will
return a function that can be used by Ember.View for rendering.
*/
-Ember.Handlebars = Ember.create(Handlebars);
+Ember.Handlebars = objectCreate(Handlebars);
-Ember.Handlebars.helpers = Ember.create(Handlebars.helpers);
+Ember.Handlebars.helpers = objectCreate(Handlebars.helpers);
/**
Override the the opcode compiler and JavaScript compiler for Handlebars.
*/
Ember.Handlebars.Compiler = function() {};
-Ember.Handlebars.Compiler.prototype = Ember.create(Handlebars.Compiler.prototype);
+Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype);
Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler;
Ember.Handlebars.JavaScriptCompiler = function() {};
-Ember.Handlebars.JavaScriptCompiler.prototype = Ember.create(Handlebars.JavaScriptCompiler.prototype);
+Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype);
Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler;
Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars";
| true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/computed.js | @@ -17,7 +17,7 @@ var meta = Ember.meta;
var guidFor = Ember.guidFor;
var USE_ACCESSORS = Ember.USE_ACCESSORS;
var a_slice = Array.prototype.slice;
-var o_create = Ember.platform.create;
+var o_create = Ember.create;
var o_defineProperty = Ember.platform.defineProperty;
// .......................................................... | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/events.js | @@ -8,7 +8,7 @@ require('ember-metal/core');
require('ember-metal/platform');
require('ember-metal/utils');
-var o_create = Ember.platform.create;
+var o_create = Ember.create;
var meta = Ember.meta;
var guidFor = Ember.guidFor;
var a_slice = Array.prototype.slice;
@@ -261,4 +261,4 @@ Ember.sendEvent = sendEvent;
Ember.hasListeners = hasListeners;
Ember.watchedEvents = watchedEvents;
Ember.listenersFor = listenersFor;
-Ember.deferEvent = deferEvent;
\ No newline at end of file
+Ember.deferEvent = deferEvent; | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/mixin.js | @@ -23,7 +23,7 @@ var a_slice = Array.prototype.slice;
var EMPTY_META = {}; // dummy for non-writable meta
var META_SKIP = { __emberproto__: true, __ember_count__: true };
-var o_create = Ember.platform.create;
+var o_create = Ember.create;
/** @private */
function meta(obj, writable) { | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/platform.js | @@ -21,29 +21,21 @@ var platform = Ember.platform = {} ;
@memberOf Ember.platform
@name create
*/
-platform.create = Object.create;
+Ember.create = Object.create;
-if (!platform.create) {
+if (!Ember.create) {
/** @private */
- var O_ctor = function() {},
- O_proto = O_ctor.prototype;
-
- platform.create = function(obj, descs) {
- O_ctor.prototype = obj;
- obj = new O_ctor();
- O_ctor.prototype = O_proto;
-
- if (descs !== undefined) {
- for(var key in descs) {
- if (!descs.hasOwnProperty(key)) continue;
- platform.defineProperty(obj, key, descs[key]);
- }
- }
+ var K = function() {};
+
+ Ember.create = function(obj) {
+ K.prototype = obj;
+ obj = new K();
+ K.prototype = null;
return obj;
};
- platform.create.isSimulated = true;
+ Ember.create.isSimulated = true;
}
Object.defineProperty = null; | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/properties.js | @@ -13,7 +13,7 @@ var USE_ACCESSORS = Ember.USE_ACCESSORS;
var GUID_KEY = Ember.GUID_KEY;
var META_KEY = Ember.META_KEY;
var meta = Ember.meta;
-var o_create = Ember.platform.create;
+var o_create = Ember.create;
var objectDefineProperty = Ember.platform.defineProperty;
var SIMPLE_PROPERTY, WATCHED_PROPERTY;
@@ -342,56 +342,3 @@ Ember.defineProperty = function(obj, keyName, desc, val) {
return this;
};
-/**
- Creates a new object using the passed object as its prototype. On browsers
- that support it, this uses the built in Object.create method. Else one is
- simulated for you.
-
- This method is a better choice than Object.create() because it will make
- sure that any observers, event listeners, and computed properties are
- inherited from the parent as well.
-
- @param {Object} obj
- The object you want to have as the prototype.
-
- @returns {Object} the newly created object
-*/
-Ember.create = function(obj, props) {
- var ret = o_create(obj, props);
- if (GUID_KEY in ret) Ember.generateGuid(ret, 'ember');
- if (META_KEY in ret) Ember.rewatch(ret); // setup watch chains if needed.
- return ret;
-};
-
-/**
- @private
-
- Creates a new object using the passed object as its prototype. This method
- acts like `Ember.create()` in every way except that bindings, observers, and
- computed properties will be activated on the object.
-
- The purpose of this method is to build an object for use in a prototype
- chain. (i.e. to be set as the `prototype` property on a constructor
- function). Prototype objects need to inherit bindings, observers and
- other configuration so they pass it on to their children. However since
- they are never 'live' objects themselves, they should not fire or make
- other changes when various properties around them change.
-
- You should use this method anytime you want to create a new object for use
- in a prototype chain.
-
- @param {Object} obj
- The base object.
-
- @param {Object} hash
- Optional hash of properties to define on the object.
-
- @returns {Object} new object
-*/
-Ember.createPrototype = function(obj, props) {
- var ret = o_create(obj, props);
- meta(ret, true).proto = ret;
- if (GUID_KEY in ret) Ember.generateGuid(ret, 'ember');
- if (META_KEY in ret) Ember.rewatch(ret); // setup watch chains if needed.
- return ret;
-}; | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/lib/utils.js | @@ -20,7 +20,7 @@ numberCache = [];
stringCache = {};
var o_defineProperty = Ember.platform.defineProperty;
-var o_create = Ember.platform.create;
+var o_create = Ember.create;
/**
@private | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/tests/binding/connect_test.js | @@ -138,6 +138,7 @@ testBoth('Bindings should be inherited', function(get, set) {
binding.connect(a);
a2 = Ember.create(a);
+ Ember.rewatch(a2);
});
equal(get(a2, 'foo'), "BAR", "Should have synced binding on child"); | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/tests/binding/sync_test.js | @@ -112,6 +112,8 @@ testBoth("bindings should do the right thing when binding is in prototype", func
a = Ember.create(proto);
b = Ember.create(proto);
+ Ember.rewatch(a);
+ Ember.rewatch(b);
});
Ember.run(function () { | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-metal/tests/platform/create_test.js | @@ -4,11 +4,11 @@
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-module("Ember.platform.create()");
+module("Ember.create()");
test("should inherit the properties from the parent object", function() {
var obj = { foo: 'FOO' };
- var obj2 = Ember.platform.create(obj);
+ var obj2 = Ember.create(obj);
ok(obj !== obj2, 'should be a new instance');
equal(obj2.foo, obj.foo, 'should inherit from parent');
@@ -19,7 +19,7 @@ test("should inherit the properties from the parent object", function() {
test("passing additional property descriptors should define", function() {
var obj = { foo: 'FOO', repl: 'obj' };
- var obj2 = Ember.platform.create(obj, {
+ var obj2 = Ember.create(obj, {
bar: {
value: 'BAR'
}, | true |
Other | emberjs | ember.js | 705638d9f9fdf59d4f43121ba8e1a0fd65fe53ba.json | Remove unnecessary variant of create | packages/ember-runtime/lib/system/core_object.js | @@ -14,7 +14,7 @@
var rewatch = Ember.rewatch;
var classToString = Ember.Mixin.prototype.toString;
var set = Ember.set, get = Ember.get;
-var o_create = Ember.platform.create,
+var o_create = Ember.create,
o_defineProperty = Ember.platform.defineProperty,
a_slice = Array.prototype.slice,
meta = Ember.meta; | true |
Other | emberjs | ember.js | 58580a70282b78d24b78c7fc39d86cd90565c41e.json | Unify some of the getter/no-getter logic | packages/ember-metal/lib/platform.js | @@ -46,6 +46,7 @@ if (!platform.create) {
platform.create.isSimulated = true;
}
+Object.defineProperty = null;
/** @private */
var defineProperty = Object.defineProperty;
var canRedefineProperties, canDefinePropertyOnDOM;
@@ -145,8 +146,7 @@ if (!platform.defineProperty) {
platform.hasPropertyAccessors = false;
platform.defineProperty = function(obj, keyName, desc) {
- Ember.assert("property descriptor cannot have `get` or `set` on this platform", !desc.get && !desc.set);
- obj[keyName] = desc.value;
+ if (!desc.get) { obj[keyName] = desc.value; }
};
platform.defineProperty.isSimulated = true; | true |
Other | emberjs | ember.js | 58580a70282b78d24b78c7fc39d86cd90565c41e.json | Unify some of the getter/no-getter logic | packages/ember-metal/lib/properties.js | @@ -14,7 +14,7 @@ var GUID_KEY = Ember.GUID_KEY;
var META_KEY = Ember.META_KEY;
var meta = Ember.meta;
var o_create = Ember.platform.create;
-var o_defineProperty = Ember.platform.defineProperty;
+var objectDefineProperty = Ember.platform.defineProperty;
var SIMPLE_PROPERTY, WATCHED_PROPERTY;
// ..........................................................
@@ -33,7 +33,7 @@ var SIMPLE_PROPERTY, WATCHED_PROPERTY;
var Descriptor = Ember.Descriptor = function() {};
var setup = Descriptor.setup = function(obj, keyName, value) {
- o_defineProperty(obj, keyName, {
+ objectDefineProperty(obj, keyName, {
writable: true,
configurable: true,
enumerable: true,
@@ -130,45 +130,36 @@ DescriptorPrototype.val = function(obj, keyName) {
// SIMPLE AND WATCHED PROPERTIES
//
-// if accessors are disabled for the app then this will act as a guard when
-// testing on browsers that do support accessors. It will throw an exception
-// if you do foo.bar instead of Ember.get(foo, 'bar')
-
// The exception to this is that any objects managed by Ember but not a descendant
// of Ember.Object will not throw an exception, instead failing silently. This
// prevent errors with other libraries that may attempt to access special
// properties on standard objects like Array. Usually this happens when copying
// an object by looping over all properties.
-
-if (!USE_ACCESSORS) {
- Ember.Descriptor.MUST_USE_GETTER = function() {
- if (this instanceof Ember.Object) {
- Ember.assert('Must use Ember.get() to access this property', false);
- }
- };
-
- Ember.Descriptor.MUST_USE_SETTER = function() {
- if (this instanceof Ember.Object) {
- if (this.isDestroyed) {
- Ember.assert('You cannot set observed properties on destroyed objects', false);
- } else {
- Ember.assert('Must use Ember.set() to access this property', false);
- }
+//
+// QUESTION: What is this scenario exactly?
+var mandatorySetter = Ember.Descriptor.MUST_USE_SETTER = function() {
+ if (this instanceof Ember.Object) {
+ if (this.isDestroyed) {
+ Ember.assert('You cannot set observed properties on destroyed objects', false);
+ } else {
+ Ember.assert('Must use Ember.set() to access this property', false);
}
- };
-}
+ }
+};
var WATCHED_DESC = {
configurable: true,
enumerable: true,
- set: Ember.Descriptor.MUST_USE_SETTER
+ set: mandatorySetter
};
/** @private */
function rawGet(obj, keyName, values) {
var ret = values[keyName];
- if (ret !== undefined) { return ret; }
- if (obj.unknownProperty) { return obj.unknownProperty(keyName); }
+ if (ret === undefined && obj.unknownProperty) {
+ ret = obj.unknownProperty(keyName);
+ }
+ return ret;
}
function get(obj, keyName) {
@@ -181,41 +172,47 @@ function watchedGet(obj, keyName) {
return rawGet(obj, keyName, meta(obj, false).values || emptyObject);
}
+var hasGetters = Ember.platform.hasPropertyAccessors, rawSet;
+
+rawSet = function(obj, keyName, value, values) {
+ values[keyName] = value;
+};
+
+// if there are no getters, keep the raw property up to date
+if (!Ember.platform.hasPropertyAccessors) {
+ rawSet = function(obj, keyName, value, values) {
+ obj[keyName] = value;
+ values[keyName] = value;
+ };
+}
+
/** @private */
function watchedSet(obj, keyName, value) {
- var m = meta(obj), changed = value !== m.values[keyName];
+ var m = meta(obj),
+ values = m.values,
+ changed = value !== values[keyName];
if (changed) {
Ember.propertyWillChange(obj, keyName);
- m.values[keyName] = value;
+ rawSet(obj, keyName, value, m.values);
Ember.propertyDidChange(obj, keyName);
}
return value;
}
-var WATCHED_GETTERS = {};
/** @private */
-function mkWatchedGetter(keyName) {
- var ret = WATCHED_GETTERS[keyName];
- if (!ret) {
- ret = WATCHED_GETTERS[keyName] = function() {
- return watchedGet(this, keyName);
- };
- }
- return ret;
+function makeWatchedGetter(keyName) {
+ return function() {
+ return watchedGet(this, keyName);
+ };
}
-var WATCHED_SETTERS = {};
/** @private */
-function mkWatchedSetter(keyName) {
- var ret = WATCHED_SETTERS[keyName];
- if (!ret) {
- ret = WATCHED_SETTERS[keyName] = function(value) {
- return watchedSet(this, keyName, value);
- };
- }
- return ret;
+function makeWatchedSetter(keyName) {
+ return function(value) {
+ return watchedSet(this, keyName, value);
+ };
}
/**
@@ -224,50 +221,25 @@ function mkWatchedSetter(keyName) {
Private version of simple property that invokes property change callbacks.
*/
WATCHED_PROPERTY = new Ember.Descriptor();
+WATCHED_PROPERTY.get = watchedGet ;
+WATCHED_PROPERTY.set = watchedSet ;
-if (Ember.platform.hasPropertyAccessors) {
- WATCHED_PROPERTY.get = watchedGet ;
- WATCHED_PROPERTY.set = watchedSet ;
-
- if (USE_ACCESSORS) {
- WATCHED_PROPERTY.setup = function(obj, keyName, value) {
- WATCHED_DESC.get = mkWatchedGetter(keyName);
- WATCHED_DESC.set = mkWatchedSetter(keyName);
- o_defineProperty(obj, keyName, WATCHED_DESC);
- WATCHED_DESC.get = WATCHED_DESC.set = null;
- if (value !== undefined) meta(obj).values[keyName] = value;
- };
-
- } else {
- WATCHED_PROPERTY.setup = function(obj, keyName, value) {
- WATCHED_DESC.get = mkWatchedGetter(keyName);
- o_defineProperty(obj, keyName, WATCHED_DESC);
- WATCHED_DESC.get = null;
- if (value !== undefined) meta(obj).values[keyName] = value;
- };
- }
-
- WATCHED_PROPERTY.teardown = function(obj, keyName) {
- var ret = meta(obj).values[keyName];
- delete meta(obj).values[keyName];
- return ret;
- };
-
-// NOTE: if platform does not have property accessors then we just have to
-// set values and hope for the best. You just won't get any warnings...
-} else {
-
- WATCHED_PROPERTY.set = function(obj, keyName, value) {
- var m = meta(obj), watching;
+WATCHED_PROPERTY.setup = function(obj, keyName, value) {
+ objectDefineProperty(obj, keyName, {
+ configurable: true,
+ enumerable: true,
+ set: mandatorySetter,
+ get: makeWatchedGetter(keyName)
+ });
- watching = m.watching[keyName]>0 && value!==obj[keyName];
- if (watching) Ember.propertyWillChange(obj, keyName);
- obj[keyName] = value;
- if (watching) Ember.propertyDidChange(obj, keyName);
- return value;
- };
+ meta(obj).values[keyName] = value;
+};
-}
+WATCHED_PROPERTY.teardown = function(obj, keyName) {
+ var ret = meta(obj).values[keyName];
+ delete meta(obj).values[keyName];
+ return ret;
+};
/**
The default descriptor for simple properties. Pass as the third argument
@@ -282,7 +254,6 @@ SIMPLE_PROPERTY = Ember.SIMPLE_PROPERTY;
SIMPLE_PROPERTY.unwatched = WATCHED_PROPERTY.unwatched = SIMPLE_PROPERTY;
SIMPLE_PROPERTY.watched = WATCHED_PROPERTY.watched = WATCHED_PROPERTY;
-
// ..........................................................
// DEFINING PROPERTIES API
//
@@ -328,16 +299,27 @@ function hasDesc(descs, keyName) {
}).property('firstName', 'lastName').cacheable());
*/
Ember.defineProperty = function(obj, keyName, desc, val) {
- var m = meta(obj, false), descs = m.descs, watching = m.watching[keyName]>0, override = true;
+ var m = meta(obj, false),
+ descs = m.descs,
+ watching = m.watching[keyName]>0,
+ override = true;
if (val === undefined) {
+ // if a value wasn't provided, the value is the old value
+ // (which can be obtained by calling teardown on a property
+ // with a descriptor).
override = false;
val = hasDesc(descs, keyName) ? descs[keyName].teardown(obj, keyName) : obj[keyName];
} else if (hasDesc(descs, keyName)) {
+ // otherwise, tear down the descriptor, but use the provided
+ // value as the new value instead of the descriptor's current
+ // value.
descs[keyName].teardown(obj, keyName);
}
- if (!desc) desc = SIMPLE_PROPERTY;
+ if (!desc) {
+ desc = SIMPLE_PROPERTY;
+ }
if (desc instanceof Ember.Descriptor) {
m = meta(obj, true);
@@ -350,7 +332,7 @@ Ember.defineProperty = function(obj, keyName, desc, val) {
// compatibility with ES5
} else {
if (descs[keyName]) meta(obj).descs[keyName] = null;
- o_defineProperty(obj, keyName, desc);
+ objectDefineProperty(obj, keyName, desc);
}
// if key is being watched, override chains that | true |
Other | emberjs | ember.js | 58580a70282b78d24b78c7fc39d86cd90565c41e.json | Unify some of the getter/no-getter logic | packages/ember-metal/tests/performance_test.js | @@ -62,7 +62,7 @@ test("computed properties are not executed if they are the last segment of an ob
Ember.addObserver(foo, 'bar.baz.bam', function() {});
- Ember.propertyDidChange(foo.bar.baz, 'bam');
+ Ember.propertyDidChange(Ember.getPath(foo, 'bar.baz'), 'bam');
equal(count, 0, "should not have recomputed property");
}); | true |
Other | emberjs | ember.js | 58580a70282b78d24b78c7fc39d86cd90565c41e.json | Unify some of the getter/no-getter logic | packages/ember-metal/tests/platform/defineProperty_test.js | @@ -63,52 +63,52 @@ test('defining a non enumerable property', function() {
}
});
-test('defining a getter/setter', function() {
- var obj = {}, getCnt = 0, setCnt = 0, v = 'FOO';
+// If accessors don't exist, behavior that relies on getters
+// and setters don't do anything
+if (Ember.platform.hasPropertyAccessors) {
+ test('defining a getter/setter', function() {
+ var obj = {}, getCnt = 0, setCnt = 0, v = 'FOO';
- var desc = {
- enumerable: true,
- get: function() { getCnt++; return v; },
- set: function(val) { setCnt++; v = val; }
- };
+ var desc = {
+ enumerable: true,
+ get: function() { getCnt++; return v; },
+ set: function(val) { setCnt++; v = val; }
+ };
- if (Ember.platform.hasPropertyAccessors) {
- Ember.platform.defineProperty(obj, 'foo', desc);
- equal(obj.foo, 'FOO', 'should return getter');
- equal(getCnt, 1, 'should have invoked getter');
+ if (Ember.platform.hasPropertyAccessors) {
+ Ember.platform.defineProperty(obj, 'foo', desc);
+ equal(obj.foo, 'FOO', 'should return getter');
+ equal(getCnt, 1, 'should have invoked getter');
- obj.foo = 'BAR';
- equal(obj.foo, 'BAR', 'setter should have worked');
- equal(setCnt, 1, 'should have invoked setter');
+ obj.foo = 'BAR';
+ equal(obj.foo, 'BAR', 'setter should have worked');
+ equal(setCnt, 1, 'should have invoked setter');
- } else {
- raises(function() {
- Ember.platform.defineProperty(obj, 'foo', desc);
- }, Error, 'should throw exception if getters/setters not supported');
- }
+ }
-});
+ });
-test('defining getter/setter along with writable', function() {
- var obj ={};
- raises(function() {
- Ember.platform.defineProperty(obj, 'foo', {
- enumerable: true,
- get: function() {},
- set: function() {},
- writable: true
- });
- }, Error, 'defining writable and get/set should throw exception');
-});
+ test('defining getter/setter along with writable', function() {
+ var obj ={};
+ raises(function() {
+ Ember.platform.defineProperty(obj, 'foo', {
+ enumerable: true,
+ get: function() {},
+ set: function() {},
+ writable: true
+ });
+ }, Error, 'defining writable and get/set should throw exception');
+ });
-test('defining getter/setter along with value', function() {
- var obj ={};
- raises(function() {
- Ember.platform.defineProperty(obj, 'foo', {
- enumerable: true,
- get: function() {},
- set: function() {},
- value: 'FOO'
- });
- }, Error, 'defining value and get/set should throw exception');
-});
+ test('defining getter/setter along with value', function() {
+ var obj ={};
+ raises(function() {
+ Ember.platform.defineProperty(obj, 'foo', {
+ enumerable: true,
+ get: function() {},
+ set: function() {},
+ value: 'FOO'
+ });
+ }, Error, 'defining value and get/set should throw exception');
+ });
+} | true |
Other | emberjs | ember.js | ad85ad9b04c4b65496e221af1ee234605904df32.json | Add rake test per package | Rakefile | @@ -128,6 +128,10 @@ task :test, [:suite] => :dist do |t, args|
"package=all&dist=build&nojshint=true"]
}
+ packages.each do |package|
+ suites[package.to_sym] = ["package=#{package}"]
+ end
+
if ENV['TEST']
opts = [ENV['TEST']]
else | false |
Other | emberjs | ember.js | ff17ce1e9ccb3b611f78a0e3dd212cd10b46a710.json | Move the binding system to Ember.Map | packages/ember-metal/lib/binding.js | @@ -9,6 +9,7 @@ require('ember-metal/accessors'); // get, getPath, setPath, trySetPath
require('ember-metal/utils'); // guidFor, isArray, meta
require('ember-metal/observer'); // addObserver, removeObserver
require('ember-metal/run_loop'); // Ember.run.schedule
+require('ember-metal/map');
// ..........................................................
// CONSTANTS
@@ -41,28 +42,23 @@ function getPathWithGlobals(obj, path) {
// ..........................................................
// BINDING
//
-/** @private */
-var K = function() {};
/** @private */
var Binding = function(toPath, fromPath) {
this._direction = 'fwd';
this._from = fromPath;
this._to = toPath;
+ this._directionMap = Ember.Map.create();
};
-K.prototype = Binding.prototype;
-
Binding.prototype = /** @scope Ember.Binding.prototype */ {
/**
This copies the Binding so it can be connected to another object.
@returns {Ember.Binding}
*/
copy: function () {
var copy = new Binding(this._to, this._from);
- if (this._oneWay) {
- copy._oneWay = true;
- }
+ if (this._oneWay) { copy._oneWay = true; }
return copy;
},
@@ -117,7 +113,7 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
@returns {Ember.Binding} receiver
*/
oneWay: function(flag) {
- this._oneWay = flag===undefined ? true : !!flag;
+ this._oneWay = true;
return this;
},
@@ -142,16 +138,17 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
connect: function(obj) {
Ember.assert('Must pass a valid object to Ember.Binding.connect()', !!obj);
- var oneWay = this._oneWay;
+ var twoWay = !this._oneWay;
// add an observer on the object to be notified when the binding should be updated
Ember.addObserver(obj, this._from, this, this.fromDidChange);
// if the binding is a two-way binding, also set up an observer on the target
// object.
- if (!oneWay) { Ember.addObserver(obj, this._to, this, this.toDidChange); }
+ if (twoWay) { Ember.addObserver(obj, this._to, this, this.toDidChange); }
- if (Ember.meta(obj,false).proto !== obj) { this._scheduleSync(obj, 'fwd'); }
+ // Don't schedule a sync if we're connecting an item on a prototype
+ if (Ember.meta(obj, false).proto !== obj) { this._scheduleSync(obj, 'fwd'); }
this._readyToSync = true;
return this;
@@ -169,14 +166,14 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
disconnect: function(obj) {
Ember.assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj);
- var oneWay = this._oneWay;
+ var twoWay = !this._oneWay;
// remove an observer on the object so we're no longer notified of
// changes that should update bindings.
Ember.removeObserver(obj, this._from, this, this.fromDidChange);
// if the binding is two-way, remove the observer from the target as well
- if (!oneWay) Ember.removeObserver(obj, this._to, this, this.toDidChange);
+ if (twoWay) { Ember.removeObserver(obj, this._to, this, this.toDidChange); }
this._readyToSync = false; // disable scheduled syncs...
return this;
@@ -198,18 +195,19 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
/** @private */
_scheduleSync: function(obj, dir) {
- var guid = guidFor(obj), existingDir = this[guid];
+ var directionMap = this._directionMap;
+ var existingDir = directionMap.get(obj);
// if we haven't scheduled the binding yet, schedule it
if (!existingDir) {
Ember.run.schedule('sync', this, this._sync, obj);
- this[guid] = dir;
+ directionMap.set(obj, dir);
}
// If both a 'back' and 'fwd' sync have been scheduled on the same object,
// default to a 'fwd' sync so that it remains deterministic.
if (existingDir === 'back' && dir === 'fwd') {
- this[guid] = 'fwd';
+ directionMap.set(obj, 'fwd');
}
},
@@ -222,11 +220,12 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
// get the direction of the binding for the object we are
// synchronizing from
- var guid = guidFor(obj), direction = this[guid];
+ var directionMap = this._directionMap;
+ var direction = directionMap.get(obj);
var fromPath = this._from, toPath = this._to;
- delete this[guid];
+ directionMap.remove(obj);
// if we're synchronizing from the remote object...
if (direction === 'fwd') { | true |
Other | emberjs | ember.js | ff17ce1e9ccb3b611f78a0e3dd212cd10b46a710.json | Move the binding system to Ember.Map | packages/ember-metal/lib/main.js | @@ -5,6 +5,7 @@
// ==========================================================================
require('ember-metal/core');
+require('ember-metal/map');
require('ember-metal/platform');
require('ember-metal/utils');
require('ember-metal/accessors'); | true |
Other | emberjs | ember.js | ff17ce1e9ccb3b611f78a0e3dd212cd10b46a710.json | Move the binding system to Ember.Map | packages/ember-runtime/lib/system.js | @@ -15,6 +15,5 @@ require('ember-runtime/system/native_array');
require('ember-runtime/system/object');
require('ember-runtime/system/set');
require('ember-runtime/system/string');
-require('ember-runtime/system/map');
require('ember-runtime/system/lazy_load'); | true |
Other | emberjs | ember.js | ff17ce1e9ccb3b611f78a0e3dd212cd10b46a710.json | Move the binding system to Ember.Map | packages/ember-runtime/lib/system/map.js | @@ -1,197 +0,0 @@
-/**
- JavaScript (before ES6) does not have a Map implementation. Objects,
- which are often used as dictionaries, may only have Strings as keys.
-
- Because Ember has a way to get a unique identifier for every object
- via `Ember.guidFor`, we can implement a performant Map with arbitrary
- keys. Because it is commonly used in low-level bookkeeping, Map is
- implemented as a pure JavaScript object for performance.
-
- This implementation follows the current iteration of the ES6 proposal
- for maps (http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets),
- with two exceptions. First, because we need our implementation to be
- pleasant on older browsers, we do not use the `delete` name (using
- `remove` instead). Second, as we do not have the luxury of in-VM
- iteration, we implement a forEach method for iteration.
-
- Map is mocked out to look like an Ember object, so you can do
- `Ember.Map.create()` for symmetry with other Ember classes.
-*/
-
-/** @private */
-var guidFor = Ember.guidFor;
-var indexOf = Ember.ArrayUtils.indexOf;
-
-// This class is used internally by Ember.js and Ember Data.
-// Please do not use it at this time. We plan to clean it up
-// and add many tests soon.
-var OrderedSet = Ember.OrderedSet = function() {
- this.clear();
-};
-
-OrderedSet.create = function() {
- return new OrderedSet();
-};
-
-OrderedSet.prototype = {
- clear: function() {
- this.presenceSet = {};
- this.list = [];
- },
-
- add: function(obj) {
- var guid = guidFor(obj),
- presenceSet = this.presenceSet,
- list = this.list;
-
- if (guid in presenceSet) { return; }
-
- presenceSet[guid] = true;
- list.push(obj);
- },
-
- remove: function(obj) {
- var guid = guidFor(obj),
- presenceSet = this.presenceSet,
- list = this.list;
-
- delete presenceSet[guid];
-
- var index = indexOf(list, obj);
- if (index > -1) {
- list.splice(index, 1);
- }
- },
-
- isEmpty: function() {
- return this.list.length === 0;
- },
-
- forEach: function(fn, self) {
- // allow mutation during iteration
- var list = this.list.slice();
-
- for (var i = 0, j = list.length; i < j; i++) {
- fn.call(self, list[i]);
- }
- },
-
- toArray: function() {
- return this.list.slice();
- }
-};
-
-/**
- A Map stores values indexed by keys. Unlike JavaScript's
- default Objects, the keys of a Map can be any JavaScript
- object.
-
- Internally, a Map has two data structures:
-
- `keys`: an OrderedSet of all of the existing keys
- `values`: a JavaScript Object indexed by the
- Ember.guidFor(key)
-
- When a key/value pair is added for the first time, we
- add the key to the `keys` OrderedSet, and create or
- replace an entry in `values`. When an entry is deleted,
- we delete its entry in `keys` and `values`.
-*/
-
-/** @private */
-var Map = Ember.Map = function() {
- this.keys = Ember.OrderedSet.create();
- this.values = {};
-};
-
-Map.create = function() {
- return new Map();
-};
-
-Map.prototype = {
- /**
- Retrieve the value associated with a given key.
-
- @param {anything} key
- @return {anything} the value associated with the key, or undefined
- */
- get: function(key) {
- var values = this.values,
- guid = guidFor(key);
-
- return values[guid];
- },
-
- /**
- Adds a value to the map. If a value for the given key has already been
- provided, the new value will replace the old value.
-
- @param {anything} key
- @param {anything} value
- */
- set: function(key, value) {
- var keys = this.keys,
- values = this.values,
- guid = guidFor(key);
-
- keys.add(key);
- values[guid] = value;
- },
-
- /**
- Removes a value from the map for an associated key.
-
- @param {anything} key
- @returns {Boolean} true if an item was removed, false otherwise
- */
- remove: function(key) {
- // don't use ES6 "delete" because it will be annoying
- // to use in browsers that are not ES6 friendly;
- var keys = this.keys,
- values = this.values,
- guid = guidFor(key),
- value;
-
- if (values.hasOwnProperty(guid)) {
- keys.remove(key);
- value = values[guid];
- delete values[guid];
- return true;
- } else {
- return false;
- }
- },
-
- /**
- Check whether a key is present.
-
- @param {anything} key
- @returns {Boolean} true if the item was present, false otherwise
- */
- has: function(key) {
- var values = this.values,
- guid = guidFor(key);
-
- return values.hasOwnProperty(guid);
- },
-
- /**
- Iterate over all the keys and values. Calls the function once
- for each key, passing in the key and value, in that order.
-
- The keys are guaranteed to be iterated over in insertion order.
-
- @param {Function} callback
- @param {anything} self if passed, the `this` value inside the
- callback. By default, `this` is the map.
- */
- forEach: function(callback, self) {
- var keys = this.keys,
- values = this.values;
-
- keys.forEach(function(key) {
- var guid = guidFor(key);
- callback.call(self, key, values[guid]);
- });
- }
-}; | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | .jshintrc | @@ -48,5 +48,6 @@
"undef": true,
"sub": true,
"strict": false,
- "white": false
+ "white": false,
+ "eqnull": true
} | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/lib/binding.js | @@ -27,111 +27,18 @@ require('ember-metal/run_loop'); // Ember.run.schedule
*/
Ember.LOG_BINDINGS = false || !!Ember.ENV.LOG_BINDINGS;
-// ..........................................................
-// TYPE COERCION HELPERS
-//
-
-// Coerces a non-array value into an array.
-/** @private */
-function MULTIPLE(val) {
- if (val instanceof Array) return val;
- if (val === undefined || val === null) return [];
- return [val];
-}
-
-// Treats a single-element array as the element. Otherwise
-// returns a placeholder.
-/** @private */
-function SINGLE(val, placeholder) {
- if (val instanceof Array) {
- if (val.length>1) return placeholder;
- else return val[0];
- }
- return val;
-}
-
-// Coerces the binding value into a Boolean.
-
-var BOOL = {
- to: function (val) {
- return !!val;
- }
-};
-
-// Returns the Boolean inverse of the value.
-var NOT = {
- to: function NOT(val) {
- return !val;
- }
-};
-
var get = Ember.get,
getPath = Ember.getPath,
setPath = Ember.setPath,
guidFor = Ember.guidFor,
isGlobalPath = Ember.isGlobalPath;
-// Applies a binding's transformations against a value.
-/** @private */
-function getTransformedValue(binding, val, obj, dir) {
-
- // First run a type transform, if it exists, that changes the fundamental
- // type of the value. For example, some transforms convert an array to a
- // single object.
-
- var typeTransform = binding._typeTransform;
- if (typeTransform) { val = typeTransform(val, binding._placeholder); }
-
- // handle transforms
- var transforms = binding._transforms,
- len = transforms ? transforms.length : 0,
- idx;
-
- for(idx=0;idx<len;idx++) {
- var transform = transforms[idx][dir];
- if (transform) { val = transform.call(this, val, obj); }
- }
- return val;
-}
-
-/** @private */
-function empty(val) {
- return val===undefined || val===null || val==='' || (Ember.isArray(val) && get(val, 'length')===0) ;
-}
/** @private */
function getPathWithGlobals(obj, path) {
return getPath(isGlobalPath(path) ? window : obj, path);
}
-/** @private */
-function getTransformedFromValue(obj, binding) {
- var operation = binding._operation,
- fromValue;
- if (operation) {
- fromValue = operation(obj, binding._from, binding._operand);
- } else {
- fromValue = getPathWithGlobals(obj, binding._from);
- }
- return getTransformedValue(binding, fromValue, obj, 'to');
-}
-
-/** @private */
-function getTransformedToValue(obj, binding) {
- var toValue = getPath(obj, binding._to);
- return getTransformedValue(binding, toValue, obj, 'from');
-}
-
-/** @private */
-var AND_OPERATION = function(obj, left, right) {
- return getPathWithGlobals(obj, left) && getPathWithGlobals(obj, right);
-};
-
-/** @private */
-var OR_OPERATION = function(obj, left, right) {
- return getPathWithGlobals(obj, left) || getPathWithGlobals(obj, right);
-};
-
// ..........................................................
// BINDING
//
@@ -170,17 +77,6 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
if (this._oneWay) {
copy._oneWay = true;
}
- if (this._transforms) {
- copy._transforms = this._transforms.slice(0);
- }
- if (this._typeTransform) {
- copy._typeTransform = this._typeTransform;
- copy._placeholder = this._placeholder;
- }
- if (this._operand) {
- copy._operand = this._operand;
- copy._operation = this._operation;
- }
return copy;
},
@@ -239,288 +135,6 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
return this;
},
- /**
- Adds the specified transform to the array of transform functions for this Binding.
-
- A transform can be either a single function or an hash with `to` and `from` properties
- that are each transform functions. If a single function is provided it will be set as the `to` transform.
-
- Transform functions accept the value to be transformed as their first argument and
- and the object with the `-Binding` property as the second argument:
-
- Transform functions must return the transformed value.
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").transform(function(value, object) {
- return ((Ember.typeOf(value) === 'number') && (value < 10)) ? 10 : value;
- })
- }),
- B: Ember.Object.create({})
- })
-
- Namespace.setPath('B.bProperty', 50)
- Namespace.getPath('A.aProperty') // 50
-
- Namespace.setPath('B.bProperty', 2)
- Namespace.getPath('A.aProperty') // 10, the minimum value
-
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").transform({
- to: function(value){
- return value.toUpperCase();
- },
- from: function(value){
- return value.toLowerCase();
- }
- })
- }),
- B: Ember.Object.create({})
- })
-
- Namespace.setPath('B.bProperty', "Hello there")
- Namespace.getPath('B.bProperty') // "Hello there"
- Namespace.getPath('A.aProperty') // "HELLO THERE", toUpperCase'd in 'to' transform
-
- Namespace.setPath('A.aProperty', "GREETINGS")
- Namespace.getPath('A.aProperty') // "GREETINGS"
- Namespace.getPath('B.bProperty') // "greetings", toLowerCase'd in 'from' transform
-
-
- Transforms are invoked in the order they were added. If you are
- extending a binding and want to reset the transforms, you can call
- `resetTransform()` first.
-
- @param {Function|Object} transform the transform function or an object containing to/from functions
- @returns {Ember.Binding} this
- */
- transform: function(transform) {
- if ('function' === typeof transform) {
- transform = { to: transform };
- }
-
- if (!this._transforms) this._transforms = [];
- this._transforms.push(transform);
- return this;
- },
-
- /**
- Resets the transforms for the binding. After calling this method the
- binding will no longer transform values. You can then add new transforms
- as needed.
-
- @returns {Ember.Binding} this
- */
- resetTransforms: function() {
- this._transforms = null;
- return this;
- },
-
- /**
- Adds a transform to the Binding instance that will allow only single values to pass.
- If the value is an array, return values will be `undefined` for `[]`, the sole item in a
- single value array or the 'Multiple Placeholder' value for arrays with more than a single item.
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").single()
- }),
- B: Ember.Object.create({})
- })
-
- Namespace.setPath('B.bProperty', 'a single value')
- Namespace.getPath('A.aProperty') // 'a single value'
-
- Namespace.setPath('B.bProperty', null)
- Namespace.getPath('A.aProperty') // null
-
- Namespace.setPath('B.bProperty', [])
- Namespace.getPath('A.aProperty') // undefined
-
- Namespace.setPath('B.bProperty', ['a single value'])
- Namespace.getPath('A.aProperty') // 'a single value'
-
- Namespace.setPath('B.bProperty', ['a value', 'another value'])
- Namespace.getPath('A.aProperty') // "@@MULT@@", the Multiple Placeholder
-
-
- You can pass in an optional multiple placeholder or the default will be used.
-
- That this transform will only happen on forward value. Reverse values are sent unchanged.
-
- @param {Object} [placeholder] Placeholder value.
- @returns {Ember.Binding} this
- */
- single: function(placeholder) {
- this._typeTransform = SINGLE;
- this._placeholder = placeholder || "@@MULT@@";
- return this;
- },
-
- /**
- Adds a transform to the Binding instance that will convert the passed value into an array. If
- the value is null or undefined, it will be converted to an empty array.
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").multiple()
- }),
- B: Ember.Object.create({
- bProperty: 'an object'
- })
- })
-
- Namespace.getPath('A.aProperty') // ["an object"]
- Namespace.setPath('B.bProperty', null)
- Namespace.getPath('A.aProperty') // []
-
- @returns {Ember.Binding} this
- */
- multiple: function() {
- this._typeTransform = MULTIPLE;
- this._placeholder = null;
- return this;
- },
-
- /**
- Adds a transform to the Binding instance to convert the value to a bool value.
- The value will return `false` for: `false`, `null`, `undefined`, `0`, and an empty string,
- otherwise it will return `true`.
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").bool()
- }),
- B: Ember.Object.create({
- bProperty: 'an object'
- })
- })
-
- Namespace.getPath('A.aProperty') // true
- Namespace.setPath('B.bProperty', false)
- Namespace.getPath('A.aProperty') // false
-
- @returns {Ember.Binding} this
- */
- bool: function() {
- this.transform(BOOL);
- return this;
- },
-
- /**
- Adds a transform to the Binding instance that will return the placeholder value
- if the value is null, undefined, an empty array or an empty string. See also notNull().
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").notEmpty("Property was empty")
- }),
- B: Ember.Object.create({
- bProperty: []
- })
- })
-
- Namespace.getPath('A.aProperty') // "Property was empty"
- Namespace.setPath('B.bProperty', [1,2])
- Namespace.getPath('A.aProperty') // [1,2]
-
- @param {Object} [placeholder] Placeholder value.
- @returns {Ember.Binding} this
- */
- notEmpty: function(placeholder) {
- if (placeholder === null || placeholder === undefined) {
- placeholder = "@@EMPTY@@";
- }
-
- this.transform({
- to: function(val) { return empty(val) ? placeholder : val; }
- });
-
- return this;
- },
-
- /**
- Adds a transform to the Binding instance that returns the placeholder value
- if the value is null or undefined. Otherwise the value will passthrough untouched:
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").notNull("Property was null")
- }),
- B: Ember.Object.create({})
- })
-
- Namespace.getPath('A.aProperty') // "Property was null"
- Namespace.setPath('B.bProperty', 'Some value')
- Namespace.getPath('A.aProperty') // 'Some value'
-
- @param {Object} [placeholder] Placeholder value.
- @returns {Ember.Binding} this
- */
- notNull: function(placeholder) {
- if (placeholder === null || placeholder === undefined) {
- placeholder = "@@EMPTY@@";
- }
-
- this.transform({
- to: function(val) { return (val === null || val === undefined) ? placeholder : val; }
- });
-
- return this;
- },
-
- /**
- Adds a transform to the Binding instance to convert the value to the inverse
- of a bool value. This uses the same transform as `bool` but inverts it:
- The value will return `true` for: `false`, `null`, `undefined`, `0`, and an empty string,
- otherwise it will return `false`
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").not()
- }),
- B: Ember.Object.create({
- bProperty: false
- })
- })
-
- Namespace.getPath('A.aProperty') // true
- Namespace.setPath('B.bProperty', true)
- Namespace.getPath('A.aProperty') // false
-
- @returns {Ember.Binding} this
- */
- not: function() {
- this.transform(NOT);
- return this;
- },
-
- /**
- Adds a transform to the Binding instance that will return true if the
- value is null or undefined, false otherwise.
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").isNull()
- }),
- B: Ember.Object.create({
- bProperty: null
- })
- })
-
- Namespace.getPath('A.aProperty') // true
- Namespace.setPath('B.bProperty', 'any value')
- Namespace.getPath('A.aProperty') // false
-
- @returns {Ember.Binding} this
- */
- isNull: function() {
- this.transform(function(val) { return val === null || val === undefined; });
- return this;
- },
-
/** @private */
toString: function() {
var oneWay = this._oneWay ? '[oneWay]' : '';
@@ -542,14 +156,11 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
connect: function(obj) {
Ember.assert('Must pass a valid object to Ember.Binding.connect()', !!obj);
- var oneWay = this._oneWay, operand = this._operand;
+ var oneWay = this._oneWay;
// add an observer on the object to be notified when the binding should be updated
Ember.addObserver(obj, this._from, this, this.fromDidChange);
- // if there is an operand, add an observer onto it as well
- if (operand) { Ember.addObserver(obj, operand, this, this.fromDidChange); }
-
// if the binding is a two-way binding, also set up an observer on the target
// object.
if (!oneWay) { Ember.addObserver(obj, this._to, this, this.toDidChange); }
@@ -572,15 +183,12 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
disconnect: function(obj) {
Ember.assert('Must pass a valid object to Ember.Binding.disconnect()', !!obj);
- var oneWay = this._oneWay, operand = this._operand;
+ var oneWay = this._oneWay;
// remove an observer on the object so we're no longer notified of
// changes that should update bindings.
Ember.removeObserver(obj, this._from, this, this.fromDidChange);
- // if there is an operand, remove the observer from it as well
- if (operand) Ember.removeObserver(obj, operand, this, this.fromDidChange);
-
// if the binding is two-way, remove the observer from the target as well
if (!oneWay) Ember.removeObserver(obj, this._to, this, this.toDidChange);
@@ -636,7 +244,7 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
// if we're synchronizing from the remote object...
if (direction === 'fwd') {
- var fromValue = getTransformedFromValue(obj, this);
+ var fromValue = getPathWithGlobals(obj, this._from);
if (log) {
Ember.Logger.log(' ', this.toString(), '->', fromValue, obj);
}
@@ -649,7 +257,7 @@ Binding.prototype = /** @scope Ember.Binding.prototype */ {
}
// if we're synchronizing *to* the remote object
} else if (direction === 'back') {// && !this._oneWay) {
- var toValue = getTransformedToValue(obj, this);
+ var toValue = getPath(obj, this._to);
if (log) {
Ember.Logger.log(' ', this.toString(), '<-', toValue, obj);
}
@@ -691,201 +299,20 @@ mixinProperties(Binding,
/**
Creates a new Binding instance and makes it apply in a single direction.
- A one-way binding will relay changes on the "from" side object (supplies
- as the `from` argument) the "to" side, but not the other way around.
+ A one-way binding will relay changes on the "from" side object (supplies
+ as the `from` argument) the "to" side, but not the other way around.
This means that if you change the "to" side directly, the "from" side may have
a different value.
-
+
@param {String} from from path.
@param {Boolean} [flag] (Optional) passing nothing here will make the binding oneWay. You can
instead pass false to disable oneWay, making the binding two way again.
-
+
@see Ember.Binding.prototype.oneWay
*/
oneWay: function(from, flag) {
var C = this, binding = new C(null, from);
return binding.oneWay(flag);
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `single` transform to its set of transforms.
-
- @param {String} from from path.
- @param {Object} [placeholder] Placeholder value.
-
- @see Ember.Binding.prototype.single
- */
- single: function(from, placeholder) {
- var C = this, binding = new C(null, from);
- return binding.single(placeholder);
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `multiple` transform to its set of transforms.
-
- @param {String} from from path.
-
- @see Ember.Binding.prototype.multiple
- */
- multiple: function(from) {
- var C = this, binding = new C(null, from);
- return binding.multiple();
- },
-
- /**
- @see Ember.Binding.prototype.transform
- */
- transform: function(from, func) {
- if (!func) {
- func = from;
- from = null;
- }
- var C = this, binding = new C(null, from);
- return binding.transform(func);
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `notEmpty` transform to its set of transforms.
-
- @param {String} from from path.
- @param {Object} [placeholder] Placeholder value.
- @see Ember.Binding.prototype.notEmpty
- */
- notEmpty: function(from, placeholder) {
- var C = this, binding = new C(null, from);
- return binding.notEmpty(placeholder);
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `notNull` transform to its set of transforms.
-
- @param {String} from from path.
- @param {Object} [placeholder] Placeholder value.
- @see Ember.Binding.prototype.notNull
- */
- notNull: function(from, placeholder) {
- var C = this, binding = new C(null, from);
- return binding.notNull(placeholder);
- },
-
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `bool` transform to its set of transforms.
-
- @param {String} from from path.
- @see Ember.Binding.prototype.bool
- */
- bool: function(from) {
- var C = this, binding = new C(null, from);
- return binding.bool();
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `not` transform to its set of transforms.
-
- @param {String} from from path.
- @see Ember.Binding.prototype.not
- */
- not: function(from) {
- var C = this, binding = new C(null, from);
- return binding.not();
- },
-
- /**
- Creates a new Binding instance, setting its `from` property the value
- of the first argument, and adds a `isNull` transform to its set of transforms.
-
- @param {String} from from path.
- @see Ember.Binding.prototype.isNull
- */
- isNull: function(from) {
- var C = this, binding = new C(null, from);
- return binding.isNull();
- },
-
- /**
- Creates a new Binding instance that forwards the logical 'AND' of values at 'pathA'
- and 'pathB' whenever either source changes.
-
- Note that the transform acts strictly as a one-way binding, working only in the direction
-
- 'pathA' AND 'pathB' --> value (value returned is the result of ('pathA' && 'pathB'))
-
- Usage example where a views's `isVisible` value is determined by
- whether something is selected in a list and whether the current user is
- allowed to delete:
-
- deleteButton: Ember.View.extend({
- isVisibleBinding: Ember.Binding.and('MyApp.itemsController.hasSelection', 'MyApp.userController.canDelete')
- })
-
- @param {String} pathA The first part of the conditional
- @param {String} pathB The second part of the conditional
- */
- and: function(pathA, pathB) {
- var C = this, binding = new C(null, pathA).oneWay();
- binding._operand = pathB;
- binding._operation = AND_OPERATION;
- return binding;
- },
-
- /**
- Creates a new Binding instance that forwards the 'OR' of values at 'pathA' and
- 'pathB' whenever either source changes. Note that the transform acts
- strictly as a one-way binding, working only in the direction
-
- 'pathA' AND 'pathB' --> value (value returned is the result of ('pathA' || 'pathB'))
-
- @param {String} pathA The first part of the conditional
- @param {String} pathB The second part of the conditional
- */
- or: function(pathA, pathB) {
- var C = this, binding = new C(null, pathA).oneWay();
- binding._operand = pathB;
- binding._operation = OR_OPERATION;
- return binding;
- },
-
- /**
- Registers a custom transform for use on any Binding:
-
- Ember.Binding.registerTransform('notLessThan', function(minValue) {
- return this.transform(function(value, binding) {
- return ((Ember.typeOf(value) === 'number') && (value < minValue)) ? minValue : value;
- });
- });
-
- Namespace = Ember.Object.create({
- A: Ember.Object.create({
- aPropertyBinding: Ember.Binding.from("Namespace.B.bProperty").notLessThan(10)
- }),
- B: Ember.Object.create({})
- })
-
- Namespace.setPath('B.bProperty', 50)
- Namespace.getPath('A.aProperty') // 50
-
- Namespace.setPath('B.bProperty', 2)
- Namespace.getPath('A.aProperty') // 10, the minimum value
-
- @param {String} name The name of the transform
- @param {Function} transform The transformation function
-
- @see Ember.Binding.prototype.transform
- */
- registerTransform: function(name, transform) {
- this.prototype[name] = transform;
- this[name] = function(from) {
- var C = this, binding = new C(null, from), args;
- args = Array.prototype.slice.call(arguments, 1);
- return binding[name].apply(binding, args);
- };
}
});
@@ -895,11 +322,11 @@ mixinProperties(Binding,
An Ember.Binding connects the properties of two objects so that whenever the
value of one property changes, the other property will be changed also.
-
+
## Automatic Creation of Bindings with `/^*Binding/`-named Properties
You do not usually create Binding objects directly but instead describe
bindings in your class or object definition using automatic binding detection.
-
+
Properties ending in a `Binding` suffix will be converted to Ember.Binding instances.
The value of this property should be a string representing a path to another object or
a custom binding instanced created using Binding helpers (see "Customizing Your Bindings"):
@@ -909,7 +336,7 @@ mixinProperties(Binding,
This will create a binding from `MyApp.someController.title` to the `value`
property of your object instance automatically. Now the two values will be
kept in sync.
-
+
## Customizing Your Bindings
In addition to synchronizing values, bindings can perform basic transforms on values.
@@ -934,7 +361,7 @@ mixinProperties(Binding,
and then check to see if the value is "empty" (null, undefined, empty array,
or an empty string). If it is empty, the value will be set to the string
"(EMPTY)".
-
+
The included transforms are: `and`, `bool`, `isNull`, `not`, `notEmpty`, `notNull`, `oneWay`,
`single`, and `multiple`
@@ -1063,7 +490,7 @@ mixinProperties(Binding,
Ember's built in binding creation method makes it easy to automatically
create bindings for you. You should always use the highest-level APIs
available, even if you understand how it works underneath.
-
+
@since Ember 0.9
*/
Ember.Binding = Binding; | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/and_test.js | @@ -1,58 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-var MyApp, set = Ember.set, get = Ember.get;
-
-module('binding/and', {
- setup: function() {
- MyApp = {
- foo: false,
- bar: false
- };
-
- Ember.run(function(){
- Ember.Binding.and("foo", "bar").to("baz").connect(MyApp);
-
- });
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('should return second item when both are truthy', function() {
- Ember.run(function(){
- set(MyApp, 'foo', true);
- set(MyApp, 'bar', 'BAR');
- });
-
- equal(get(MyApp, 'baz'), 'BAR', 'should be false');
-});
-
-test('should return false first item', function() {
- Ember.run(function(){
- set(MyApp, 'foo', 0);
- set(MyApp, 'bar', true);
- });
- equal(get(MyApp, 'baz'), 0, 'should be false');
-});
-
-test('should return false second item', function() {
- Ember.run(function(){
- set(MyApp, 'foo', true);
- set(MyApp, 'bar', 0);
- });
- equal(get(MyApp, 'baz'), 0, 'should be false');
-});
-
-test('should return first item when both are false', function() {
- Ember.run(function(){
- set(MyApp, 'foo', 0);
- set(MyApp, 'bar', null);
- });
- equal(get(MyApp, 'baz'), 0, 'should be false');
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/bool_not_test.js | @@ -1,79 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-function testBool(val, expected) {
- test('Forces '+Object.prototype.toString.call(val)+' value to '+expected, function() {
- Ember.run(function(){
- Ember.set(MyApp.foo, 'value', val);
- });
-
- equal(Ember.get(MyApp.bar, 'value'), expected);
- });
-}
-
-module('system/binding/bool', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
-
- Ember.run(function(){
- Ember.bind(MyApp, 'bar.value', 'foo.value').bool();
- });
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-testBool(true, true);
-testBool('STRING', true);
-testBool(23, true);
-testBool({ object: 123 }, true);
-testBool([1,2,3], true);
-testBool([], true);
-
-testBool(false, false);
-testBool(null, false);
-testBool(undefined, false);
-testBool(0, false);
-testBool('', false);
-
-
-module('system/binding/not', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
-
- Ember.run(function(){
- Ember.bind(MyApp, 'bar.value', 'foo.value').not();
- });
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-testBool(true, false);
-testBool('STRING', false);
-testBool(23, false);
-testBool({ object: 123 }, false);
-testBool([1,2,3], false);
-testBool([], false);
-
-testBool(false, true);
-testBool(null, true);
-testBool(undefined, true);
-testBool(0, true);
-testBool('', true);
-
- | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/multiple_test.js | @@ -1,49 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-module('system/binding/multiple', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('forces binding values to be multiple', function() {
- var binding;
- Ember.run(function(){
- binding = Ember.bind(MyApp, 'bar.value', 'foo.value').multiple();
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), ['FOO'], '1 MyApp.bar.value');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', ['BAR']);
- });
-
- deepEqual(Ember.getPath('MyApp.foo.value'), ['BAR'], '2 MyApp.foo.value');
- deepEqual(Ember.getPath('MyApp.bar.value'), ['BAR'], '2 MyApp.bar.value');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', ['BAR', 'BAZ']);
- });
-
- deepEqual(Ember.getPath('MyApp.foo.value'), ['BAR', 'BAZ'], '3 MyApp.foo.value');
- deepEqual(Ember.getPath('MyApp.bar.value'), ['BAR', 'BAZ'], '3 MyApp.bar.value');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', null);
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), [], '4 MyApp.bar.value');
-
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/notEmpty_test.js | @@ -1,41 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-module('system/binding/notEmpty', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('forces binding values to be notEmpty if enumerable', function() {
- var binding;
- Ember.run(function(){
- binding = Ember.bind(MyApp, 'bar.value', 'foo.value').notEmpty('(EMPTY)');
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), 'FOO', '1 MyApp.bar.value');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', ['FOO']);
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), ['FOO'], '2 Array passes through');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', []);
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), '(EMPTY)', '3 uses empty placeholder');
-
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/notNull_test.js | @@ -1,36 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-module('system/binding/notNull', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('allow empty string as placeholder', function() {
- var binding;
- Ember.run(function(){
- binding = Ember.bind(MyApp, 'bar.value', 'foo.value').notNull('');
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), 'FOO', 'value passes through');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', null);
- });
-
- deepEqual(Ember.getPath('MyApp.bar.value'), '', 'null gets replaced');
-
-});
- | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/or_test.js | @@ -1,60 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-
-var MyApp, set = Ember.set, get = Ember.get;
-
-module('binding/or', {
- setup: function() {
- MyApp = {
- foo: false,
- bar: false
- };
- Ember.run(function(){
- Ember.Binding.or("foo", "bar").to("baz").connect(MyApp);
- });
-
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('should return first item when both are truthy', function() {
- Ember.run(function(){
- set(MyApp, 'foo', 'FOO');
- set(MyApp, 'bar', 'BAR');
- });
-
- equal(get(MyApp, 'baz'), 'FOO', 'should be false');
-});
-
-test('should return true first item', function() {
- Ember.run(function(){
- set(MyApp, 'foo', 1);
- set(MyApp, 'bar', false);
- });
-
- equal(get(MyApp, 'baz'), 1, 'should be false');
-});
-
-test('should return true second item', function() {
- Ember.run(function(){
- set(MyApp, 'foo', false);
- set(MyApp, 'bar', 10);
- });
-
- equal(get(MyApp, 'baz'), 10, 'should be false');
-});
-
-test('should return second item when both are false', function() {
- Ember.run(function(){
- set(MyApp, 'foo', null);
- set(MyApp, 'bar', 0);
- });
-
- equal(get(MyApp, 'baz'), 0, 'should be false');
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/registerTransform_test.js | @@ -1,65 +0,0 @@
-// ==========================================================================
-// Project: Ember Metal
-// Copyright: ©2012 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-module('system/binding/registerTransform', {
- setup: function() {
- Ember.Binding.registerTransform('gt', function(min) {
- return this.transform(function(value, binding) {
- return value > min;
- });
- });
-
- MyApp = {
- foo: 0
- };
- },
-
- teardown: function() {
- delete Ember.Binding.gt;
- delete Ember.Binding.prototype.gt;
- MyApp = null;
- }
-});
-
-test('registerTransform registers a custom transform for use in a binding', function() {
- var binding;
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo', 0);
-
- binding = Ember.bind(MyApp, 'bar', 'foo').gt(0);
- });
-
- equal(Ember.getPath('MyApp.bar'), false);
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo', 1);
- });
-
- equal(Ember.getPath('MyApp.bar'), true);
-
- binding.disconnect(MyApp);
-});
-
-test('registerTransform adds a class method to Ember.Binding', function() {
- var binding;
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo', 0);
- binding = Ember.Binding.gt('foo', 0).to('baz').connect(MyApp);
- });
-
- equal(Ember.getPath('MyApp.baz'), false);
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo', 1);
- });
-
- equal(Ember.getPath('MyApp.baz'), true);
-
- binding.disconnect(MyApp);
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/single_test.js | @@ -1,69 +0,0 @@
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-var get = Ember.get, set = Ember.set;
-
-module('system/binding/single', {
- setup: function() {
- MyApp = {
- foo: { value: 'FOO' },
- bar: { value: 'BAR' }
- };
- },
-
- teardown: function() {
- MyApp = null;
- }
-});
-
-test('forces binding values to be single', function() {
- var binding;
- Ember.run(function(){
- binding = Ember.bind(MyApp, 'bar.value', 'foo.value').single();
- });
-
-
- equal(Ember.getPath('MyApp.bar.value'), 'FOO', 'passes single object');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', ['BAR']);
- });
-
- equal(Ember.getPath('MyApp.bar.value'), 'BAR', 'passes single object');
-
- Ember.run(function(){
- Ember.setPath('MyApp.foo.value', ['BAR', 'BAZ']);
- });
-
- equal(Ember.getPath('MyApp.bar.value'), "@@MULT@@", 'converts to placeholder');
-});
-
-test('Ember.Binding#single(fromPath, placeholder) is available', function() {
- var binding;
-
- var obj = {
- value: null,
- boundValue: null
- };
-
- Ember.run(function(){
- binding = Ember.Binding.single('value', 'placeholder').to('boundValue').connect(obj);
- });
-
- equal(get(obj, 'boundValue'), null, 'intial boundValue is null');
-
- Ember.run(function(){
- set(obj, 'value', [1]);
- });
-
- equal(get(obj, 'boundValue'), 1, 'passes single object');
-
- Ember.run(function(){
- set(obj, 'value', [1, 2]);
- });
-
- equal(get(obj, 'boundValue'), 'placeholder', 'converts to placeholder');
-}); | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/sync_test.js | @@ -130,52 +130,6 @@ testBoth("bindings should do the right thing when binding is in prototype", func
equal(get(obj, 'selection'), 'a');
});
-testBoth("binding with transform should only fire one change when set", function (get, set) {
- var a, b, changed, transform;
-
- Ember.run(function() {
- a = {array: null};
- b = {a: a};
- changed = 0;
-
- Ember.addObserver(a, 'array', function() {
- changed++;
- });
-
- transform = {
- to: function(array) {
- if (array) {
- return array.join(',');
- } else {
- return array;
- }
- },
- from: function(string) {
- if (string) {
- return string.split(',');
- } else {
- return string;
- }
- }
- };
- Ember.Binding.from('a.array').to('string').transform(transform).connect(b);
- });
-
- Ember.run(function() {
- set(a, 'array', ['a', 'b', 'c']);
- });
-
- equal(changed, 1);
- equal(get(b, 'string'), 'a,b,c');
-
- Ember.run(function() {
- set(b, 'string', '1,2,3');
- });
-
- equal(changed, 2);
- deepEqual(get(a, 'array'), ['1','2','3']);
-});
-
testBoth("bindings should not try to sync destroyed objects", function(get, set) {
var a, b;
| true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-metal/tests/binding/transform_test.js | @@ -1,157 +0,0 @@
-// ==========================================================================
-// Project: Ember Runtime
-// Copyright: ©2011 Strobe Inc. and contributors.
-// License: Licensed under MIT license (see license.js)
-// ==========================================================================
-/*globals MyApp:true */
-
-var foo, bar, binding, set = Ember.set, get = Ember.get, setPath = Ember.setPath;
-
-var CountObject = function(data){
- for (var item in data){
- this[item] = data[item];
- }
-
- Ember.addObserver(this, 'value', this.valueDidChange);
-};
-
-CountObject.prototype = {
- value: null,
-
- _count: 0,
-
- reset: function() {
- this._count = 0;
- return this;
- },
-
- valueDidChange: function() {
- this._count++;
- }
-};
-
-module('system/mixin/binding/transform_test', {
- setup: function() {
- MyApp = {
- foo: new CountObject({ value: 'FOO' }),
- bar: new CountObject({ value: 'BAR' })
- };
-
- foo = Ember.getPath('MyApp.foo');
- bar = Ember.getPath('MyApp.bar');
- },
-
- teardown: function() {
- binding.disconnect(MyApp);
- MyApp = null;
- }
-});
-
-test('returns this', function() {
- binding = new Ember.Binding('foo.value', 'bar.value');
-
- var ret = binding.transform({ from: function() {}, to: function() {} });
- equal(ret, binding);
-});
-
-test('transform function should be invoked on fwd change', function() {
-
- Ember.run(function(){
- binding = Ember.bind(MyApp, 'foo.value', 'bar.value');
- binding.transform({ to: function(value) { return 'TRANSFORMED'; }});
- Ember.run.sync();
- });
-
- // should have transformed...
- equal(Ember.getPath('MyApp.foo.value'), 'TRANSFORMED', 'should transform');
- equal(Ember.getPath('MyApp.bar.value'), 'BAR', 'should stay original');
-});
-
-test('two-way transforms work', function() {
- Ember.run(function() {
- binding = Ember.bind(MyApp, 'foo.value', 'bar.value');
- binding.transform({
- to: function(string) {
- return parseInt(string, 10) || null;
- },
- from: function(integer) {
- return String(integer);
- }
- });
- });
-
- Ember.run(function() {
- setPath(MyApp, 'bar.value', "1");
- });
-
- equal(Ember.getPath('MyApp.foo.value'), 1, "sets the value to a number");
-
- setPath(MyApp, 'foo.value', 1);
- equal(Ember.getPath('MyApp.bar.value'), "1", "sets the value to a string");
-});
-
-test('transform function should NOT be invoked on fwd change', function() {
-
- Ember.run(function(){
- var count = 0;
- binding = Ember.bind(MyApp, 'foo.value', 'bar.value');
- var lastSeenValue;
- binding.transform({
- to: function(value) {
- if (value !== lastSeenValue) count++; // transform must be consistent
- lastSeenValue = value;
- return 'TRANSFORMED '+count;
- }
- });
-
- Ember.run.sync();
-
- // should have transformed...
- foo.reset();
- bar.reset();
-
- Ember.setPath('MyApp.bar.value', 'FOOBAR');
- Ember.run.sync();
- });
-
-
- equal(Ember.getPath('MyApp.foo.value'), 'TRANSFORMED 2', 'should transform');
- equal(Ember.getPath('MyApp.bar.value'), 'FOOBAR', 'should stay original');
-
- equal(foo._count, 1, 'observer should have fired on set');
- equal(bar._count, 1, 'observer should have fired on set');
-});
-
-test('transforms should chain', function() {
- Ember.run(function () {
- binding = Ember.bind(MyApp, 'foo.value', 'bar.value');
- binding.transform({
- to: function(value) { return value+' T1'; }
- });
- binding.transform({
- to: function(value) { return value+' T2'; }
- });
- });
-
- // should have transformed...
- equal(Ember.getPath('MyApp.foo.value'), 'BAR T1 T2', 'should transform');
- equal(Ember.getPath('MyApp.bar.value'), 'BAR', 'should stay original');
-});
-
-test('resetTransforms() should clear', function() {
- Ember.run(function () {
- binding = Ember.bind(MyApp, 'foo.value', 'bar.value');
- binding.transform({
- to: function(value) { return value+' T1'; }
- });
- binding.resetTransforms();
- binding.transform({
- to: function(value) { return value+' T2'; }
- });
- });
-
- // should have transformed...
- equal(Ember.getPath('MyApp.foo.value'), 'BAR T2', 'should transform');
- equal(Ember.getPath('MyApp.bar.value'), 'BAR', 'should stay original');
-});
- | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-runtime/tests/legacy_1x/system/binding_test.js | @@ -231,38 +231,6 @@ module("Custom Binding", {
}
});
-test("Binding value1 such that it will recieve only single values", function() {
- var bon1 = Bon1.create({
- value1Binding: Ember.Binding.single("TestNamespace.bon2.val1"),
- array1Binding: Ember.Binding.single("TestNamespace.bon2.arr")
- });
- Ember.run.sync();
- var a = [23,31,12,21];
- set(bon2, "arr", a);
- set(bon2, "val1","changed");
- Ember.run.sync();
- equal(get(bon2, "val1"),get(bon1, "value1"));
- equal("@@MULT@@",get(bon1, "array1"));
-
- Ember.run.end();
-});
-
-test("Binding with transforms, function to check the type of value", function() {
- var jon = Bon1.create({
- value1Binding: Ember.Binding.transform({
- to: function(val1) {
- return (Ember.typeOf(val1) === 'string')? val1 : "";
- }
- }).from("TestNamespace.bon2.val1")
- });
- Ember.run.sync();
- set(bon2, "val1","changed");
- Ember.run.sync();
- equal(get(jon, "value1"), get(bon2, "val1"));
-
- Ember.run.end();
-});
-
test("two bindings to the same value should sync in the order they are initialized", function() {
Ember.run.begin();
@@ -296,145 +264,6 @@ test("two bindings to the same value should sync in the order they are initializ
equal(get(b.c, 'foo'), "bar", 'a.foo should propagate up to b.c.foo');
});
-// ..........................................................
-// AND BINDING
-//
-
-module("AND binding", {
-
- setup: function() {
- // temporarily set up two source objects in the Ember namespace so we can
- // use property paths to access them
- Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: false }));
- Ember.set(Ember, 'testControllerB', Ember.Object.create({ value: false }));
-
- toObject = Ember.Object.create({
- value: null,
- valueBinding: Ember.Binding.and('Ember.testControllerA.value', 'Ember.testControllerB.value')
- });
- },
-
- teardown: function() {
- set(Ember, 'testControllerA', null);
- set(Ember, 'testControllerB', null);
- Ember.run.end();
- Ember.run.cancelTimers();
- }
-
-});
-
-test("toObject.value should be true if both sources are true", function() {
- Ember.run.begin();
- set(Ember.testControllerA, 'value', true);
- set(Ember.testControllerB, 'value', true);
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), true);
-});
-
-test("toObject.value should be false if either source is false", function() {
- Ember.run.begin();
- set(Ember.testControllerA, 'value', true);
- set(Ember.testControllerB, 'value', false);
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), false);
-
- Ember.run.begin();
- set(Ember.testControllerA, 'value', true);
- set(Ember.testControllerB, 'value', true);
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), true);
-
- Ember.run.begin();
- set(Ember.testControllerA, 'value', false);
- set(Ember.testControllerB, 'value', true);
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), false);
-});
-
-// ..........................................................
-// OR BINDING
-//
-
-module("OR binding", {
- setup: function() {
- // temporarily set up two source objects in the Ember namespace so we can
- // use property paths to access them
- Ember.set(Ember, 'testControllerA', Ember.Object.create({ value: false }));
- Ember.set(Ember, 'testControllerB', Ember.Object.create({ value: null }));
-
- toObject = Ember.Object.create({
- value: null,
- valueBinding: Ember.Binding.or('Ember.testControllerA.value', 'Ember.testControllerB.value')
- });
- },
-
- teardown: function() {
- set(Ember, 'testControllerA', null);
- set(Ember, 'testControllerB', null);
-
- Ember.run.end();
- Ember.run.cancelTimers();
- }
-
-});
-
-test("toObject.value should be first value if first value is truthy", function() {
- Ember.run.begin();
- set(Ember.testControllerA, 'value', 'first value');
- set(Ember.testControllerB, 'value', 'second value');
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), 'first value');
-});
-
-test("toObject.value should be second value if first is falsy", function() {
- Ember.run.begin();
- set(Ember.testControllerA, 'value', false);
- set(Ember.testControllerB, 'value', 'second value');
- Ember.run.end();
-
- Ember.run.sync();
- equal(get(toObject, 'value'), 'second value');
-});
-
-// ..........................................................
-// BINDING WITH []
-//
-
-module("Binding with '[]'", {
- setup: function() {
- fromObject = Ember.Object.create({ value: Ember.A() });
- toObject = Ember.Object.create({ value: '' });
- root = { toObject: toObject, fromObject: fromObject };
-
- binding = Ember.bind(root, 'toObject.value', 'fromObject.value.[]').transform(function(v) {
- return v ? v.join(',') : '';
- });
- },
-
- teardown: function() {
- root = fromObject = toObject = null;
- Ember.run.end();
- Ember.run.cancelTimers();
- }
-});
-
-test("Binding refreshes after a couple of items have been pushed in the array", function() {
- get(fromObject, 'value').pushObjects(['foo', 'bar']);
- Ember.run.sync();
- equal(get(toObject, 'value'), 'foo,bar');
-});
-
-
// ..........................................................
// propertyNameBinding with longhand
// | true |
Other | emberjs | ember.js | 7ae011753e595086287f06733028b260e0526847.json | Remove binding transforms
I'm willing to bring them back if there is a
very compelling use-case vs. computed properties. | packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js | @@ -84,26 +84,6 @@ test("bind(.bar) should bind to relative path", function() {
equal("changedValue", get(testObject, "foo"), "testObject.foo");
});
-test("Ember.Binding.bool(TestNamespace.fromObject.bar)) should create binding with bool transform", function() {
- Ember.run(function(){
- // create binding
- testObject.bind("foo", Ember.Binding.bool("TestNamespace.fromObject.bar"));
-
- // now make a change to see if the binding triggers.
- set(fromObject, "bar", 1);
- });
-
-
- equal(true, get(testObject, "foo"), "testObject.foo == true");
-
- Ember.run(function(){
- set(fromObject, "bar", 0);
- });
-
-
- equal(false, get(testObject, "foo"), "testObject.foo == false");
-});
-
var fooBindingModuleOpts = {
setup: function() {
@@ -165,26 +145,6 @@ test("fooBinding: .bar should bind to relative path", function() {
equal("changedValue", get(testObject, "foo"), "testObject.foo");
});
-test("fooBinding: Ember.Binding.bool(TestNamespace.fromObject.bar should create binding with bool transform", function() {
-
- Ember.run(function(){
- testObject = TestObject.create({
- fooBinding: Ember.Binding.bool("TestNamespace.fromObject.bar")
- });
-
- // now make a change to see if the binding triggers.
- set(fromObject, "bar", 1);
- });
-
- equal(true, get(testObject, "foo"), "testObject.foo == true");
-
- Ember.run(function(){
- set(fromObject, "bar", 0);
- });
-
- equal(false, get(testObject, "foo"), "testObject.foo == false");
-});
-
test('fooBinding: should disconnect bindings when destroyed', function () {
Ember.run(function(){
testObject = TestObject.create({ | true |
Other | emberjs | ember.js | 495002207212709f47af6612a5ec3467ddba45ac.json | Simplify accessor code a bit | packages/ember-metal/lib/accessors.js | @@ -248,27 +248,31 @@ Ember.getPath = function(root, path) {
Ember.setPath = function(root, path, value, tolerant) {
var keyName;
- if (arguments.length===2 && 'string' === typeof root) {
+ if (IS_GLOBAL.test(root)) {
value = path;
path = root;
root = null;
}
-
if (path.indexOf('.') > 0) {
- keyName = path.slice(path.lastIndexOf('.')+1);
+ // get the last part of the path
+ keyName = path.slice(path.lastIndexOf('.') + 1);
+
+ // get the first part of the part
path = path.slice(0, path.length-(keyName.length+1));
+
+ // unless the path is this, look up the first part to
+ // get the root
if (path !== 'this') {
root = Ember.getPath(root, path);
}
-
} else {
- if (IS_GLOBAL.test(path)) throw new Error('Invalid Path');
+ Ember.assert("A global path passed to setPath must have at least one period", !IS_GLOBAL.test(path) || path.indexOf(".") > -1);
keyName = path;
}
- if (!keyName || keyName.length===0 || keyName==='*') {
- throw new Error('Invalid Path');
+ if (!keyName || keyName.length === 0) {
+ throw new Error('You passed an empty path');
}
if (!root) {
@@ -287,12 +291,6 @@ Ember.setPath = function(root, path, value, tolerant) {
an object has been destroyed.
*/
Ember.trySetPath = function(root, path, value) {
- if (arguments.length===2 && 'string' === typeof root) {
- value = path;
- path = root;
- root = null;
- }
-
return Ember.setPath(root, path, value, true);
};
| true |
Other | emberjs | ember.js | 495002207212709f47af6612a5ec3467ddba45ac.json | Simplify accessor code a bit | packages/ember-metal/tests/accessors/setPath_test.js | @@ -47,12 +47,6 @@ test('[obj, foo] -> obj.foo', function() {
equal(Ember.getPath(obj, 'foo'), "BAM");
});
-test('[obj, *] -> EXCEPTION [cannot set *]', function() {
- raises(function() {
- Ember.setPath(obj, '*', "BAM");
- }, Error);
-});
-
test('[obj, foo.bar] -> obj.foo.bar', function() {
Ember.setPath(obj, 'foo.bar', "BAM");
equal(Ember.getPath(obj, 'foo.bar'), "BAM"); | true |
Other | emberjs | ember.js | 8b4d82b2ceda5d5b09f5f25a4af366e757481b82.json | Add brief documentation for Ember.Object | packages/ember-runtime/lib/system/object.js | @@ -12,6 +12,11 @@ Ember.CoreObject.subclasses = new Ember.Set();
/**
@class
+
+ `Ember.Object` is the main base class for all Ember objects. It is a subclass
+ of `Ember.CoreObject` with the `Ember.Observable` mixin applied. For details,
+ see the documentation for each of these.
+
@extends Ember.CoreObject
@extends Ember.Observable
*/ | false |
Other | emberjs | ember.js | a73ba1c2e222f477eb49f33b80203ea776970584.json | Add documentation for Ember.Mixin | packages/ember-metal/lib/mixin.js | @@ -323,7 +323,30 @@ Ember.mixin = function(obj) {
/**
- @constructor
+ @class
+
+ The `Ember.Mixin` class allows you to create mixins, whose properties can be
+ added to other classes. For instance,
+
+ App.Editable = Ember.Mixin.create({
+ edit: function() {
+ console.log('starting to edit');
+ this.set('isEditing', true);
+ },
+ isEditing: false
+ });
+
+ // Mix mixins into classes by passing them as the first arguments to
+ // .extend or .create.
+ App.CommentView = Ember.View.extend(App.Editable, {
+ template: Ember.Handlebars.compile('{{#if isEditing}}...{{else}}...{{/if}}')
+ });
+
+ commentView = App.CommentView.create();
+ commentView.edit(); // => outputs 'starting to edit'
+
+ Note that Mixins are created with `Ember.Mixin.create`, not
+ `Ember.Mixin.extend`.
*/
Ember.Mixin = function() { return initMixin(this, arguments); };
| false |
Other | emberjs | ember.js | 0dddf2d70cf7bff3dffbd9b0ae9be3af2220e798.json | add examples to Array#objectsAt | packages/ember-runtime/lib/mixins/array.js | @@ -93,7 +93,11 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
},
/**
- This returns the objects at the specified indexes, using objectAt.
+ This returns the objects at the specified indexes, using `objectAt`.
+
+ var arr = ['a', 'b', 'c', 'd'];
+ arr.objectsAt([0, 1, 2]) => ["a", "b", "c"]
+ arr.objectsAt([2, 3, 4]) => ["c", "d", undefined]
@param {Array} indexes
An array of indexes of items to return. | false |
Other | emberjs | ember.js | eb62b083150d3777ba11c0efbbacc64052d98457.json | Fix bug where the wrong context was being passed | packages/ember-states/lib/state.js | @@ -102,8 +102,8 @@ Ember.State = Ember.Object.extend(Ember.Evented, {
});
Ember.State.transitionTo = function(target) {
- var event = function(router, context) {
- router.transitionTo(target, context);
+ var event = function(router, event) {
+ router.transitionTo(target, event.context);
};
event.transitionTarget = target; | false |
Other | emberjs | ember.js | 059ceb0f72ad0f54a022f61d621d73b9470f1b16.json | Allow Handlebars rc1 | packages/ember-handlebars/lib/ext.js | @@ -19,7 +19,7 @@ require("ember-views/system/render_buffer");
@description Helpers for Handlebars templates
*/
-Ember.assert("Ember Handlebars requires Handlebars 1.0.beta.5 or greater", window.Handlebars && window.Handlebars.VERSION.match(/^1\.0\.beta\.[56789]$/));
+Ember.assert("Ember Handlebars requires Handlebars 1.0.beta.5 or greater", window.Handlebars && window.Handlebars.VERSION.match(/^1\.0\.beta\.[56789]$|^1\.0\.rc\.[123456789]+/));
/**
@class | false |
Other | emberjs | ember.js | d1d4a47d1d6291ad596a2b8c1d4a6f18f7a5191d.json | Fix syntax error in action_url_test | packages/ember-application/tests/system/action_url_test.js | @@ -1,7 +1,7 @@
// FIXME: Move this to an integration test pacakge with proper requires
try {
require('ember-handlebars');
-} catch() { }
+} catch(e) { }
module("the {{action}} helper with href attribute");
| false |
Other | emberjs | ember.js | bf9400510f00a2962bb36162eae642c56731a34a.json | Fix paths with leading periods | packages/ember-handlebars/lib/ext.js | @@ -161,7 +161,7 @@ var normalizePath = Ember.Handlebars.normalizePath = function(root, path, data)
} else {
// Strip the keyword from the path and look up
// the remainder from the newly found root.
- path = path.substr(keyword.length);
+ path = path.substr(keyword.length+1);
}
}
| true |
Other | emberjs | ember.js | bf9400510f00a2962bb36162eae642c56731a34a.json | Fix paths with leading periods | packages/ember-handlebars/tests/handlebars_test.js | @@ -245,7 +245,7 @@ test("child views can be inserted using the {{view}} Handlebars helper", functio
test("should accept relative paths to views", function() {
view = Ember.View.create({
- template: Ember.Handlebars.compile('Hey look, at {{view ".myCool.view"}}'),
+ template: Ember.Handlebars.compile('Hey look, at {{view "myCool.view"}}'),
myCool: Ember.Object.create({
view: Ember.View.extend({ | true |
Other | emberjs | ember.js | 0b8cd8dbe42da615d965ae29ac29011600ead61a.json | Simplify getPath code to use split(".") | packages/ember-metal/lib/accessors.js | @@ -135,23 +135,14 @@ Ember.set = set;
// PATHS
//
-// assumes normalized input; no *, normalized path, always a target...
/** @private */
function getPath(target, path) {
- var len = path.length, idx, next, key;
-
- idx = 0;
- while(target && idx<len) {
- next = path.indexOf('.', idx);
- if (next<0) next = len;
- key = path.slice(idx, next);
- target = get(target, key);
-
+ var parts = path.split(".");
+ for (var i=0, l=parts.length; target && i<l; i++) {
+ target = get(target, parts[i]);
if (target && target.isDestroyed) { return undefined; }
-
- idx = next+1;
}
- return target ;
+ return target;
}
var TUPLE_RET = []; | false |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-metal/lib/accessors.js | @@ -23,7 +23,7 @@ var meta = Ember.meta;
var get, set;
/** @private */
-get = function get(obj, keyName) {
+var basicGet = function get(obj, keyName) {
var ret = obj[keyName];
if (ret !== undefined) { return ret; }
@@ -35,7 +35,7 @@ get = function get(obj, keyName) {
};
/** @private */
-set = function set(obj, keyName, value) {
+var basicSet = function set(obj, keyName, value) {
var isObject = 'object' === typeof obj;
var hasProp = isObject && !(keyName in obj);
@@ -49,38 +49,26 @@ set = function set(obj, keyName, value) {
} else {
obj[keyName] = value;
}
- return value;
};
-if (!USE_ACCESSORS) {
-
- var o_get = get, o_set = set;
-
- /** @private */
- get = function(obj, keyName) {
- if (keyName === undefined && 'string' === typeof obj) {
- keyName = obj;
- obj = Ember;
- }
-
- Ember.assert("You need to provide an object and key to `get`.", !!obj && keyName);
+/** @private */
+get = function(obj, keyName) {
+ Ember.assert("You need to provide an object and key to `get`.", !!obj && keyName);
- if (!obj) return undefined;
- var desc = meta(obj, false).descs[keyName];
- if (desc) return desc.get(obj, keyName);
- else return o_get(obj, keyName);
- };
+ var desc = meta(obj, false).descs[keyName];
+ if (desc) { return desc.get(obj, keyName); }
+ else { return basicGet(obj, keyName); }
+};
- /** @private */
- set = function(obj, keyName, value) {
- Ember.assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined);
- var desc = meta(obj, false).descs[keyName];
- if (desc) desc.set(obj, keyName, value);
- else o_set(obj, keyName, value);
- return value;
- };
+/** @private */
+set = function(obj, keyName, value) {
+ Ember.assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined);
-}
+ var desc = meta(obj, false).descs[keyName];
+ if (desc) { desc.set(obj, keyName, value); }
+ else { basicSet(obj, keyName, value); }
+ return value;
+};
/**
@function
@@ -147,21 +135,9 @@ Ember.set = set;
// PATHS
//
-/** @private */
-function cleanupStars(path) {
- if (path.indexOf('*') === -1 || path === '*') return path;
-
- Ember.deprecate('Star paths are now treated the same as normal paths', !/(^|[^\.])\*/.test(path));
-
- return path.replace(/(^|.)\*/, function(match, char){
- return (char === '.') ? match : (char + '.');
- });
-}
-
/** @private */
function normalizePath(path) {
Ember.assert('must pass non-empty string to normalizePath()', path && path!=='');
- path = cleanupStars(path);
if (path==='*') return path; //special case...
var first = path.charAt(0);
@@ -172,9 +148,12 @@ function normalizePath(path) {
// assumes normalized input; no *, normalized path, always a target...
/** @private */
function getPath(target, path) {
- var len = path.length, idx, next, key;
+ if (path === undefined) {
+ path = target;
+ target = Ember;
+ }
- path = cleanupStars(path);
+ var len = path.length, idx, next, key;
idx = 0;
while(target && idx<len) {
@@ -211,8 +190,6 @@ function normalizeTuple(target, path) {
if (!target || isGlobal) target = window;
if (hasThis) path = path.slice(5);
- path = cleanupStars(path);
-
if (target === window) {
key = firstKey(path);
target = get(target, key);
@@ -280,8 +257,6 @@ Ember.getPath = function(root, path) {
root = null;
}
- path = cleanupStars(path);
-
// If there is no root and path is a key name, return that
// property from the global object.
// E.g. getPath('Ember') -> Ember | true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-metal/tests/accessors/getPath_test.js | @@ -90,57 +90,3 @@ test('[null, Foo.bar] -> Foo.bar', function() {
deepEqual(Ember.getPath('Foo.bar'), Foo.bar);
});
-// ..........................................................
-// DEPRECATED
-//
-
-module('Ember.getPath - deprecated', {
- setup: function() {
- Ember.TESTING_DEPRECATION = true;
- moduleOpts.setup();
- },
- teardown: function() {
- Ember.TESTING_DEPRECATION = false;
- moduleOpts.teardown();
- }
-});
-
-test('[obj, foo*bar] -> obj.foo.bar', function() {
- deepEqual(Ember.getPath(obj, 'foo*bar'), obj.foo.bar);
-});
-
-test('[obj, foo*bar.*] -> obj.foo.bar', function() {
- deepEqual(Ember.getPath(obj, 'foo*bar.*'), obj.foo.bar);
-});
-
-test('[obj, foo.bar*baz.biff] -> obj.foo.bar.baz.biff', function() {
- deepEqual(Ember.getPath(obj, 'foo.bar*baz.biff'), obj.foo.bar.baz.biff);
-});
-
-test('[obj, *foo.bar] -> obj.foo.bar', function() {
- deepEqual(Ember.getPath(obj, '*foo.bar'), obj.foo.bar);
-});
-
-test('[obj, this.foo*bar] -> obj.foo.bar', function() {
- deepEqual(Ember.getPath(obj, 'this.foo*bar'), obj.foo.bar);
-});
-
-test('[obj, this.foo.bar*baz.biff] -> obj.foo.bar.baz.biff', function() {
- deepEqual(Ember.getPath(obj, 'this.foo.bar*baz.biff'), obj.foo.bar.baz.biff);
-});
-
-test('[obj, foo.bar*baz.biff] -> obj.foo.bar.baz.biff', function() {
- deepEqual(Ember.getPath(obj, 'foo.bar*baz.biff'), obj.foo.bar.baz.biff);
-});
-
-test('[null, Foo*bar] -> Foo.bar', function() {
- deepEqual(Ember.getPath('Foo*bar'), Foo.bar);
-});
-
-test('[null, Foo.bar*baz.biff] -> Foo.bar.baz.biff', function() {
- deepEqual(Ember.getPath('Foo.bar*baz.biff'), Foo.bar.baz.biff);
-});
-
-test('[null, Foo.bar.baz*biff] -> Foo.bar.baz.biff', function() {
- deepEqual(Ember.getPath('Foo.bar.baz*biff'), Foo.bar.baz.biff);
-}); | true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-metal/tests/accessors/normalizePath_test.js | @@ -22,12 +22,3 @@ test('.foo.bar -> this.foo.bar', function() {
equal(Ember.normalizePath('.foo.bar'), 'this.foo.bar');
});
-test('*foo.bar -> this.foo.bar', function() {
- Ember.TESTING_DEPRECATION = true;
- try {
- equal(Ember.normalizePath('*foo.bar'), 'this.foo.bar');
- } finally {
- Ember.TESTING_DEPRECATION = false;
- }
-});
- | true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-metal/tests/accessors/normalizeTuple_test.js | @@ -105,70 +105,3 @@ test('[null, Foo] -> EXCEPTION', function() {
test('[null, Foo.bar] -> [Foo, bar]', function() {
deepEqual(Ember.normalizeTuple(null, 'Foo.bar'), [Foo, 'bar']);
});
-
-// ..........................................................
-// DEPRECATED
-//
-//
-module('Ember.normalizeTuple - deprecated', {
- setup: function() {
- Ember.TESTING_DEPRECATION = true;
- moduleOpts.setup();
- },
- teardown: function() {
- Ember.TESTING_DEPRECATION = false;
- moduleOpts.teardown();
- }
-});
-
-test('[obj, foo*bar] -> [obj, foo.bar]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'foo*bar'), [obj, 'foo.bar']);
-});
-
-test('[obj, foo*bar.*] -> [obj, foo.bar.*]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'foo*bar.*'), [obj, 'foo.bar.*']);
-});
-
-test('[obj, foo.bar*baz.biff] -> [obj, foo.bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'foo.bar*baz.biff'), [obj, 'foo.bar.baz.biff']);
-});
-
-test('[obj, *foo.bar] -> [obj, foo.bar]', function() {
- deepEqual(Ember.normalizeTuple(obj, '*foo.bar'), [obj, 'foo.bar']);
-});
-
-test('[obj, this.foo*bar] -> [obj, foo.bar]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'this.foo*bar'), [obj, 'foo.bar']);
-});
-
-test('[obj, this.foo.bar*baz.biff] -> [obj, foo.bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'this.foo.bar*baz.biff'), [obj, 'foo.bar.baz.biff']);
-});
-
-test('[obj, this.foo.bar*baz.biff] -> [obj, foo.bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'foo.bar*baz.biff'), [obj, 'foo.bar.baz.biff']);
-});
-
-test('[null, Foo*bar] -> [Foo, bar]', function() {
- deepEqual(Ember.normalizeTuple(null, 'Foo*bar'), [Foo, 'bar']);
-});
-
-test('[null, Foo.bar*baz.biff] -> [Foo, bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(null, 'Foo.bar*baz.biff'), [Foo, 'bar.baz.biff']);
-});
-
-test('[null, Foo.bar.baz*biff] -> [Foo, bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(null, 'Foo.bar.baz*biff'), [Foo, 'bar.baz.biff']);
-});
-
-test('[obj, Foo*bar] -> [Foo, bar]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'Foo*bar'), [Foo, 'bar']);
-});
-
-test('[obj, Foo.bar*baz.biff] -> [Foo, bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'Foo.bar*baz.biff'), [Foo, 'bar.baz.biff']);
-});
-
-test('[obj, Foo.bar.baz*biff] -> [Foo, bar.baz.biff]', function() {
- deepEqual(Ember.normalizeTuple(obj, 'Foo.bar.baz*biff'), [Foo, 'bar.baz.biff']);
-}); | true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-metal/tests/accessors/setPath_test.js | @@ -108,52 +108,6 @@ module("Ember.setPath - deprecated", {
}
});
-test('[obj, foo*bar] -> obj.foo.bar', function() {
- Ember.setPath(obj, 'foo*bar', "BAM");
- equal(Ember.getPath(obj, 'foo.bar'), "BAM");
-});
-
-test('[obj, foo*bar.*] -> EXCEPTION', function() {
- raises(function() {
- Ember.setPath(obj, 'foo.*.baz.*', "BAM");
- }, Error);
-});
-
-test('[obj, foo.bar*baz.biff] -> obj.foo.bar.baz.biff', function() {
- Ember.setPath(obj, 'foo.bar*baz.biff', "BAM");
- equal(Ember.getPath(obj, 'foo.bar.baz.biff'), "BAM");
-});
-
-test('[obj, *foo.bar] -> obj.foo.bar', function() {
- Ember.setPath(obj, '*foo.bar', "BAM");
- equal(Ember.getPath(obj, 'foo.bar'), "BAM");
-});
-
-test('[obj, this.foo*bar] -> obj.foo.bar', function() {
- Ember.setPath(obj, 'this.foo*bar', "BAM");
- equal(Ember.getPath(obj, 'foo.bar'), "BAM");
-});
-
-test('[obj, this.foo.bar*baz.biff] -> obj.foo.bar.baz.biff', function() {
- Ember.setPath(obj, 'this.foo.bar*baz.biff', "BAM");
- equal(Ember.getPath(obj, 'foo.bar.baz.biff'), "BAM");
-});
-
-test('[null, Foo*bar] -> Foo.bar', function() {
- Ember.setPath(null, 'Foo*bar', "BAM");
- equal(Ember.getPath(Foo, 'bar'), "BAM");
-});
-
-test('[null, Foo.bar*baz.biff] -> Foo.bar.baz.biff', function() {
- Ember.setPath(null, 'Foo.bar*baz.biff', "BAM");
- equal(Ember.getPath(Foo, 'bar.baz.biff'), "BAM");
-});
-
-test('[null, Foo.bar.baz*biff] -> Foo.bar.baz.biff', function() {
- Ember.setPath(null, 'Foo.bar.baz*biff', "BAM");
- equal(Ember.getPath(Foo, 'bar.baz.biff'), "BAM");
-});
-
test('[obj, Foo] -> EXCEPTION', function() {
raises(function() {
Ember.setPath(obj, 'Foo', "BAM"); | true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js | @@ -169,7 +169,6 @@ test("raise if the provided object is undefined", function() {
test("should work when object is Ember (used in Ember.getPath)", function() {
equal(Ember.getPath('Ember.RunLoop'), Ember.RunLoop, 'Ember.getPath');
- equal(Ember.get('RunLoop'), Ember.RunLoop, 'Ember.get(RunLoop)');
equal(Ember.get(Ember, 'RunLoop'), Ember.RunLoop, 'Ember.get(Ember, RunLoop)');
});
| true |
Other | emberjs | ember.js | 6a1cc57e9380fedb9b3b9eadd37ac06cfb5267c2.json | Remove deprecated functionality
* Ember.get("foo") is now an error
* * paths inside of a path are now an error | packages/ember-runtime/tests/legacy_1x/system/object/bindings_test.js | @@ -104,55 +104,6 @@ test("Ember.Binding.bool(TestNamespace.fromObject.bar)) should create binding wi
equal(false, get(testObject, "foo"), "testObject.foo == false");
});
-
-module("bind() method - deprecated", {
- setup: function() {
- Ember.TESTING_DEPRECATION = true;
- bindModuleOpts.setup();
- },
- teardown: function() {
- Ember.TESTING_DEPRECATION = false;
- bindModuleOpts.teardown();
- }
-});
-
-test("bind(TestNamespace.fromObject*extraObject.foo) should create chained binding", function() {
- Ember.run(function(){
- testObject.bind("foo", "TestNamespace.fromObject*extraObject.foo");
- set(fromObject, "extraObject", extraObject);
- });
-
- equal("extraObjectValue", get(testObject, "foo"), "testObject.foo") ;
-});
-
-test("bind(*extraObject.foo) should create locally chained binding", function() {
- Ember.run(function(){
- testObject.bind("foo", "*extraObject.foo");
- set(testObject, "extraObject", extraObject);
- });
-
- equal("extraObjectValue", get(testObject, "foo"), "testObject.foo") ;
-});
-
-
-// The following contains no test
-test("bind(*extraObject.foo) should be disconnectable", function() {
- var binding;
- Ember.run(function(){
- binding = testObject.bind("foo", "*extraObject.foo");
- });
-
- binding.disconnect(testObject);
-
- Ember.run(function(){
- set(testObject, 'extraObject', extraObject);
- });
-
- // there was actually a bug here - the binding above should have synced to
- // null as there was no original value
- equal(null, get(testObject, "foo"), "testObject.foo after disconnecting");
-});
-
var fooBindingModuleOpts = {
setup: function() {
@@ -253,39 +204,3 @@ test('fooBinding: should disconnect bindings when destroyed', function () {
ok(get(testObject, 'foo') !== 'bar', 'binding should not have synced');
});
-
-
-module("fooBinding method - deprecated", {
- setup: function() {
- Ember.TESTING_DEPRECATION = true;
- fooBindingModuleOpts.setup();
- },
- teardown: function() {
- Ember.TESTING_DEPRECATION = false;
- fooBindingModuleOpts.teardown();
- }
-});
-
-test("fooBinding: TestNamespace.fromObject*extraObject.foo should create chained binding", function() {
-
- Ember.run(function(){
- testObject = TestObject.create({
- fooBinding: "TestNamespace.fromObject*extraObject.foo"
- });
-
- set(fromObject, "extraObject", extraObject);
- });
-
- equal("extraObjectValue", get(testObject, "foo"), "testObject.foo") ;
-});
-
-test("fooBinding: *extraObject.foo should create locally chained binding", function() {
- Ember.run(function(){
- testObject = TestObject.create({
- fooBinding: "*extraObject.foo"
- });
- set(testObject, "extraObject", extraObject);
- });
-
- equal("extraObjectValue", get(testObject, "foo"), "testObject.foo") ;
-}); | true |
Other | emberjs | ember.js | f3d80406a69dd98dd4465e30de0d6b37633821e7.json | Remove legacy support for set via unknownProperty
If you want setUnknownProperty, implement
setUnknownProperty. | packages/ember-metal/lib/accessors.js | @@ -39,12 +39,16 @@ get = function get(obj, keyName) {
/** @private */
set = function set(obj, keyName, value) {
- if (('object'===typeof obj) && !(keyName in obj)) {
- if ('function' === typeof obj.setUnknownProperty) {
- obj.setUnknownProperty(keyName, value);
- } else if ('function' === typeof obj.unknownProperty) {
- obj.unknownProperty(keyName, value);
- } else obj[keyName] = value;
+ var isObject = 'object' === typeof obj;
+ var hasProp = isObject && !(keyName in obj);
+
+ // setUnknownProperty is called if `obj` is an object,
+ // the property does not already exist, and the
+ // `setUnknownProperty` method exists on the object
+ var unknownProp = hasProp && 'function' === typeof obj.setUnknownProperty;
+
+ if (unknownProp) {
+ obj.setUnknownProperty(keyName, value);
} else {
obj[keyName] = value;
} | true |
Other | emberjs | ember.js | f3d80406a69dd98dd4465e30de0d6b37633821e7.json | Remove legacy support for set via unknownProperty
If you want setUnknownProperty, implement
setUnknownProperty. | packages/ember-metal/tests/accessors/set_test.js | @@ -26,22 +26,6 @@ test('should set arbitrary properties on an object', function() {
});
-test('should call unknownProperty if defined and value is undefined', function() {
-
- var obj = {
- count: 0,
- unknownProperty: function(key, value) {
- equal(key, 'foo', 'should pass key');
- equal(value, 'BAR', 'should pass key');
- this.count++;
- return 'FOO';
- }
- };
-
- equal(Ember.set(obj, 'foo', "BAR"), 'BAR', 'should return set value');
- equal(obj.count, 1, 'should have invoked');
-});
-
test('should call setUnknownProperty if defined and value is undefined', function() {
var obj = { | true |
Other | emberjs | ember.js | b456370644ba1472544389a2bf7f4d2bce6fc287.json | Remove unused code | tests/index.html | @@ -76,8 +76,6 @@
var noViewPreservesContext = QUnit.urlParams.noviewpreservescontext;
ENV['VIEW_PRESERVES_CONTEXT'] = !noViewPreservesContext;
- ENV['PREVENT_AUTOMATIC_RUNLOOP_CREATION'] = true;
-
// Don't worry about jQuery version
ENV['FORCE_JQUERY'] = true;
</script> | false |
Other | emberjs | ember.js | 3ff2d411108a8f893c2c5d0eb9c886a233a542e0.json | fix build by checking VIEW_PRESERVES_CONTEXT | packages/ember-views/tests/views/view/template_test.js | @@ -7,6 +7,8 @@
var set = Ember.set, get = Ember.get;
+var VIEW_PRESERVES_CONTEXT = Ember.VIEW_PRESERVES_CONTEXT;
+
module("Ember.View - Template Functionality");
test("should call the function of the associated template", function() {
@@ -26,7 +28,6 @@ test("should call the function of the associated template", function() {
view.createElement();
});
-
ok(view.$('#twas-called').length, "the named template was called");
});
@@ -49,7 +50,6 @@ test("should call the function of the associated template with itself as the con
view.createElement();
});
-
equal("template was called for Tom DAAAALE", view.$('#twas-called').text(), "the named template was called with the view as the data source");
});
@@ -84,7 +84,6 @@ test("should not use defaultTemplate if template is provided", function() {
view.createElement();
});
-
equal("foo", view.$().text(), "default template was not printed");
});
@@ -104,22 +103,22 @@ test("should not use defaultTemplate if template is provided", function() {
view.createElement();
});
-
equal("foo", view.$().text(), "default template was not printed");
});
-
test("should render an empty element if no template is specified", function() {
var view;
+
view = Ember.View.create();
Ember.run(function(){
view.createElement();
});
+
equal(view.$().html(), '', "view div should be empty");
});
test("should provide a controller to the template if a controller is specified on the view", function() {
- expect(7);
+ expect(VIEW_PRESERVES_CONTEXT ? 7 : 5);
var Controller1 = Ember.Object.extend({
toString: function() { return "Controller1"; }
@@ -181,7 +180,6 @@ test("should provide a controller to the template if a controller is specified o
parentView.destroy();
});
-
var parentViewWithControllerlessChild = Ember.View.create({
controller: controller1,
@@ -203,6 +201,9 @@ test("should provide a controller to the template if a controller is specified o
strictEqual(optionsDataKeywordsControllerForView, controller1, "passes the original controller in the data");
strictEqual(optionsDataKeywordsControllerForChildView, controller1, "passes the controller in the data to child views");
- strictEqual(contextForView, controller2, "passes the controller in as the main context of the parent view");
- strictEqual(contextForControllerlessView, controller1, "passes the controller in as the main context of the child view");
+
+ if (VIEW_PRESERVES_CONTEXT) {
+ strictEqual(contextForView, controller2, "passes the controller in as the main context of the parent view");
+ strictEqual(contextForControllerlessView, controller1, "passes the controller in as the main context of the child view");
+ }
}); | false |
Other | emberjs | ember.js | 9b09cf37d0e8908ee8cd8a41920596a1f6509324.json | Improve error when creating URLs from action | packages/ember-states/lib/router.js | @@ -45,7 +45,7 @@ Ember.Router = Ember.StateManager.extend(
var currentState = get(this, 'currentState');
var targetStateName = currentState.eventTransitions[eventName];
- Ember.assert("You must specify a target state for an event in order to get links for an event", !!targetStateName);
+ Ember.assert(Ember.String.fmt("You must specify a target state for event '%@' in order to link to it in the current state '%@'.", [eventName, get(currentState, 'path')]), !!targetStateName);
var targetState = this.findStateByPath(currentState, targetStateName);
| false |
Other | emberjs | ember.js | a1f9a1f085ec2e6c7d16aedd992f76882791c5ce.json | update String#objectAt documentation | packages/ember-runtime/lib/mixins/array.js | @@ -4,11 +4,8 @@
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
require('ember-runtime/mixins/enumerable');
-
-
// ..........................................................
// HELPERS
//
@@ -66,20 +63,29 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
/**
@field {Number} length
- Your array must support the length property. Your replace methods should
+ Your array must support the length property. Your replace methods should
set this property whenever it changes.
*/
length: Ember.required(),
/**
- This is one of the primitives you must implement to support Ember.Array.
- Returns the object at the named index. If your object supports retrieving
- the value of an array item using get() (i.e. myArray.get(0)), then you do
- not need to implement this method yourself.
+ Returns the object at the given index. If the given index is negative or
+ is greater or equal than the array length, returns `undefined`.
+
+ This is one of the primitives you must implement to support `Ember.Array`.
+ If your object supports retrieving the value of an array item using `get()`
+ (i.e. `myArray.get(0)`), then you do not need to implement this method
+ yourself.
+
+ var arr = ['a', 'b', 'c', 'd'];
+ arr.objectAt(0); => "a"
+ arr.objectAt(3); => "d"
+ arr.objectAt(-1); => undefined
+ arr.objectAt(4); => undefined
+ arr.objectAt(5); => undefined
@param {Number} idx
- The index of the item to return. If idx exceeds the current length,
- return null.
+ The index of the item to return.
*/
objectAt: function(idx) {
if ((idx < 0) || (idx>=get(this, 'length'))) return undefined ;
@@ -131,7 +137,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
// Add any extra methods to Ember.Array that are native to the built-in Array.
/**
- Returns a new array that is a slice of the receiver. This implementation
+ Returns a new array that is a slice of the receiver. This implementation
uses the observable array methods to retrieve the objects for the new
slice.
@@ -390,9 +396,4 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
return this.__each;
}).property().cacheable()
-
-
}) ;
-
-
- | false |
Other | emberjs | ember.js | 3b277ec1f34da51c3ed4f7aa2da52c2ac70a9734.json | Fix references to _BindableSpan | packages/ember-handlebars/lib/helpers/binding.js | @@ -56,7 +56,7 @@ var bind = function(property, options, preserveContext, shouldDisplay, valueNorm
};
// Observes the given property on the context and
- // tells the Ember._BindableSpan to re-render. If property
+ // tells the Ember._HandlebarsBoundView to re-render. If property
// is an empty string, we are printing the current context
// object ({{this}}) so updating it is not our responsibility.
if (path !== '') { | true |
Other | emberjs | ember.js | 3b277ec1f34da51c3ed4f7aa2da52c2ac70a9734.json | Fix references to _BindableSpan | packages/ember-handlebars/lib/views/handlebars_bound_view.js | @@ -134,7 +134,7 @@ Ember._HandlebarsBoundView = Ember._MetamorphView.extend({
true, the `displayTemplate` function will be rendered to DOM. Otherwise,
`inverseTemplate`, if specified, will be rendered.
- For example, if this Ember._BindableSpan represented the {{#with foo}}
+ For example, if this Ember._HandlebarsBoundView represented the {{#with foo}}
helper, it would look up the `foo` property of its context, and
`shouldDisplayFunc` would always return true. The object found by looking
up `foo` would be passed to `displayTemplate`. | true |
Other | emberjs | ember.js | 37fbe405e2bb5fe7b10a96713148771edaff1919.json | Fix misuse of setProperties | packages/ember-views/lib/system/render_buffer.js | @@ -225,7 +225,7 @@ Ember._RenderBuffer.prototype =
var buffer = new Ember._RenderBuffer(tagName);
buffer.parentBuffer = parent;
- if (other) { buffer.setProperties(other); }
+ if (other) { Ember.$.extend(buffer, other); }
if (fn) { fn.call(this, buffer); }
return buffer; | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.