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 | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/lib/mixins/view_target_action_support.js | @@ -14,7 +14,7 @@ For example:
```javascript
App.SaveButtonView = Ember.View.extend(Ember.ViewTargetActionSupport, {
action: 'save',
- click: function(){
+ click: function() {
this.triggerAction(); // Sends the `save` action, along with the current context
// to the current controller
}
@@ -26,7 +26,7 @@ to `triggerAction` as well.
```javascript
App.SaveButtonView = Ember.View.extend(Ember.ViewTargetActionSupport, {
- click: function(){
+ click: function() {
this.triggerAction({
action: 'save'
}); // Sends the `save` action, along with the current context | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/lib/system/render_buffer.js | @@ -455,7 +455,7 @@ Ember._RenderBuffer.prototype =
if (this._hasElement && this._element) {
// Firefox versions < 11 do not have support for element.outerHTML.
var thisElement = this.element(), outerHTML = thisElement.outerHTML;
- if (typeof outerHTML === 'undefined'){
+ if (typeof outerHTML === 'undefined') {
return Ember.$('<div/>').append(thisElement).html();
}
return outerHTML;
@@ -488,7 +488,7 @@ Ember._RenderBuffer.prototype =
var string = value.toString();
- if(!possible.test(string)) { return string; }
+ if (!possible.test(string)) { return string; }
return string.replace(badChars, escapeChar);
}
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/lib/system/utils.js | @@ -9,7 +9,7 @@
// is a "zero-scope" element. This problem can be worked around by making
// the first node an invisible text node. We, like Modernizr, use ­
-var needsShy = this.document && (function(){
+var needsShy = this.document && (function() {
var testEl = document.createElement('div');
testEl.innerHTML = "<div></div>";
testEl.firstChild.innerHTML = "<script></script>"; | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/lib/views/view.js | @@ -18,7 +18,7 @@ var childViewsProperty = Ember.computed(function() {
a_forEach(childViews, function(view) {
var currentChildViews;
if (view.isVirtual) {
- if(currentChildViews = get(view, 'childViews')) {
+ if (currentChildViews = get(view, 'childViews')) {
ret.pushObjects(currentChildViews);
}
} else {
@@ -315,8 +315,8 @@ class:
MyView = Ember.View.extend({
classNameBindings: ['propertyA', 'propertyB'],
propertyA: 'from-a',
- propertyB: function(){
- if(someLogic){ return 'from-b'; }
+ propertyB: function() {
+ if (someLogic) { return 'from-b'; }
}.property()
});
```
@@ -497,7 +497,7 @@ class:
MyTextInput = Ember.View.extend({
tagName: 'input',
attributeBindings: ['disabled'],
- disabled: function(){
+ disabled: function() {
if (someLogic) {
return true;
} else {
@@ -606,7 +606,7 @@ class:
aController = Ember.Object.create({
firstName: 'Barry',
- excitedGreeting: function(){
+ excitedGreeting: function() {
return this.get("content.firstName") + "!!!"
}.property()
});
@@ -677,7 +677,7 @@ class:
```javascript
AView = Ember.View.extend({
- click: function(event){
+ click: function(event) {
// will be called when when an instance's
// rendered element is clicked
}
@@ -698,7 +698,7 @@ class:
```javascript
AView = Ember.View.extend({
eventManager: Ember.Object.create({
- doubleClick: function(event, view){
+ doubleClick: function(event, view) {
// will be called when when an instance's
// rendered element or any rendering
// of this views's descendent
@@ -713,11 +713,11 @@ class:
```javascript
AView = Ember.View.extend({
- mouseEnter: function(event){
+ mouseEnter: function(event) {
// will never trigger.
},
eventManager: Ember.Object.create({
- mouseEnter: function(event, view){
+ mouseEnter: function(event, view) {
// takes presedence over AView#mouseEnter
}
})
@@ -735,7 +735,7 @@ class:
OuterView = Ember.View.extend({
template: Ember.Handlebars.compile("outer {{#view InnerView}}inner{{/view}} outer"),
eventManager: Ember.Object.create({
- mouseEnter: function(event, view){
+ mouseEnter: function(event, view) {
// view might be instance of either
// OuterView or InnerView depending on
// where on the page the user interaction occured
@@ -744,12 +744,12 @@ class:
});
InnerView = Ember.View.extend({
- click: function(event){
+ click: function(event) {
// will be called if rendered inside
// an OuterView because OuterView's
// eventManager doesn't handle click events
},
- mouseEnter: function(event){
+ mouseEnter: function(event) {
// will never be called if rendered inside
// an OuterView.
}
@@ -1060,7 +1060,7 @@ Ember.View = Ember.CoreView.extend(
var view = get(this, 'parentView');
while (view) {
- if(view instanceof klass) { return view; }
+ if (view instanceof klass) { return view; }
view = get(view, 'parentView');
}
},
@@ -1081,7 +1081,7 @@ Ember.View = Ember.CoreView.extend(
function(view) { return klass.detect(view.constructor); };
while (view) {
- if( isOfType(view) ) { return view; }
+ if (isOfType(view)) { return view; }
view = get(view, 'parentView');
}
},
@@ -1114,7 +1114,7 @@ Ember.View = Ember.CoreView.extend(
var view = get(this, 'parentView');
while (view) {
- if(get(view, 'parentView') instanceof klass) { return view; }
+ if (get(view, 'parentView') instanceof klass) { return view; }
view = get(view, 'parentView');
}
},
@@ -2224,7 +2224,7 @@ Ember.View = Ember.CoreView.extend(
}
var view = this,
- stateCheckedObserver = function(){
+ stateCheckedObserver = function() {
view.currentState.invokeObserver(this, observer);
},
scheduledObserver = function() { | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/system/ext_test.js | @@ -7,7 +7,7 @@ test("View hierarchy is done rendering to DOM when functions queued in afterRend
render: function(buffer) {
buffer.push('child');
},
- didInsertElement: function(){
+ didInsertElement: function() {
this.$().addClass('extra-class');
}
});
@@ -19,7 +19,7 @@ test("View hierarchy is done rendering to DOM when functions queued in afterRend
},
didInsertElement: function() {
lookup1 = this.$('.extra-class');
- Ember.run.scheduleOnce('afterRender', this, function(){
+ Ember.run.scheduleOnce('afterRender', this, function() {
lookup2 = this.$('.extra-class');
});
}
@@ -32,7 +32,7 @@ test("View hierarchy is done rendering to DOM when functions queued in afterRend
equal(lookup1.length, 0, "doesn't not find child in DOM on didInsertElement");
equal(lookup2.length, 1, "finds child in DOM afterRender");
- Ember.run(function(){
+ Ember.run(function() {
parentView.destroy();
});
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/system/render_buffer_test.js | @@ -88,12 +88,12 @@ test("handles null props - Issue #2019", function() {
equal('<span></span><div>', buffer.string());
});
-test("handles browsers like Firefox < 11 that don't support outerHTML Issue #1952", function(){
+test("handles browsers like Firefox < 11 that don't support outerHTML Issue #1952", function() {
var buffer = new Ember.RenderBuffer('div');
buffer.pushOpeningTag();
// Make sure element.outerHTML is falsy to trigger the fallback.
var elementStub = '<div></div>';
- buffer.element = function(){ return elementStub; };
+ buffer.element = function() { return elementStub; };
// IE8 returns `element name as upper case with extra whitespace.
equal(elementStub, buffer.string().toLowerCase().replace(/\s/g, ''));
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/collection_test.js | @@ -8,7 +8,7 @@ module("Ember.CollectionView", {
},
teardown: function() {
delete Ember.CollectionView.CONTAINER_MAP.del;
- Ember.run(function(){
+ Ember.run(function() {
if (view) { view.destroy(); }
});
}
@@ -543,7 +543,7 @@ test("a array_proxy that backs an sorted array_controller that backs a collectio
test("when a collection view is emptied, deeply nested views elements are not removed from the DOM and then destroyed again", function() {
var assertProperDestruction = Ember.Mixin.create({
destroyElement: function() {
- if ( this.state === 'inDOM' ) {
+ if (this.state === 'inDOM') {
ok(this.get('element'), this + ' still exists in DOM');
}
return this._super(); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/container_view_test.js | @@ -34,7 +34,7 @@ test("should be able to insert views after the DOM representation is created", f
equal(view._parentView, container, 'view\'s _parentView is the container');
equal(Ember.$.trim(container.$().text()), "This is my moment");
- Ember.run(function(){
+ Ember.run(function() {
container.destroy();
});
@@ -79,7 +79,7 @@ test("should set the parentView property on views that are added to the child vi
container.appendTo('#qunit-fixture');
});
- Ember.run(function(){
+ Ember.run(function() {
container.pushObject(view);
});
@@ -89,7 +89,7 @@ test("should set the parentView property on views that are added to the child vi
thirdView = View.create(),
fourthView = View.create();
- Ember.run(function(){
+ Ember.run(function() {
container.pushObject(secondView);
container.replace(1, 0, [thirdView, fourthView]);
});
@@ -607,13 +607,13 @@ test("Child view can only be added to one container at a time", function () {
container.set('currentView', view);
});
- expectAssertion(function(){
+ expectAssertion(function() {
Ember.run(function() {
secondContainer.set('currentView', view);
});
});
- expectAssertion(function(){
+ expectAssertion(function() {
Ember.run(function() {
secondContainer.pushObject(view);
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/append_to_test.js | @@ -8,7 +8,7 @@ module("Ember.View - append() and appendTo()", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
if (!view.isDestroyed) { view.destroy(); }
});
}
@@ -46,16 +46,16 @@ test("should be added to the document body when calling append()", function() {
ok(viewElem.length > 0, "creates and appends the view's element");
});
-test("append calls willInsertElement and didInsertElement callbacks", function(){
+test("append calls willInsertElement and didInsertElement callbacks", function() {
var willInsertElementCalled = false;
var willInsertElementCalledInChild = false;
var didInsertElementCalled = false;
var ViewWithCallback = View.extend({
- willInsertElement: function(){
+ willInsertElement: function() {
willInsertElementCalled = true;
},
- didInsertElement: function(){
+ didInsertElement: function() {
didInsertElementCalled = true;
},
render: function(buffer) {
@@ -144,7 +144,7 @@ module("Ember.View - append() and appendTo() in a view hierarchy", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
if (!view.isDestroyed) { view.destroy(); }
});
}
@@ -197,7 +197,7 @@ module("Ember.View - removing views in a view hierarchy", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
if (!view.isDestroyed) { view.destroy(); }
});
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/attribute_bindings_test.js | @@ -13,7 +13,7 @@ module("Ember.View - Attribute Bindings", {
},
teardown: function() {
if (view) {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
view = null;
@@ -37,7 +37,7 @@ test("should render attribute bindings", function() {
notNumber: NaN
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -67,7 +67,7 @@ test("should update attribute bindings", function() {
explosions: 15
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -81,7 +81,7 @@ test("should update attribute bindings", function() {
ok(view.$().prop('notNumber'), "adds notNumber attribute when true");
equal(view.$().attr('explosions'), "15", "adds integer attributes");
- Ember.run(function(){
+ Ember.run(function() {
view.set('type', 'submit');
view.set('isDisabled', false);
view.set('exploded', false);
@@ -109,10 +109,10 @@ test("should allow binding to String objects", function() {
view = Ember.View.create({
attributeBindings: ['foo'],
// JSHint doesn't like `new String` so we'll create it the same way it gets created in practice
- foo: (function(){ return this; }).call("bar")
+ foo: (function() { return this; }).call("bar")
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -214,20 +214,20 @@ test("handles a 0 value attribute on text fields", function() {
strictEqual(view.$().prop('value'), "0", "value should be 0");
});
-test("attributeBindings should not fail if view has been removed", function(){
- Ember.run(function(){
+test("attributeBindings should not fail if view has been removed", function() {
+ Ember.run(function() {
view = Ember.View.create({
attributeBindings: ['checked'],
checked: true
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
var error;
try {
- Ember.run(function(){
- Ember.changeProperties(function(){
+ Ember.run(function() {
+ Ember.changeProperties(function() {
view.set('checked', false);
view.remove();
});
@@ -238,20 +238,20 @@ test("attributeBindings should not fail if view has been removed", function(){
ok(!error, error);
});
-test("attributeBindings should not fail if view has been destroyed", function(){
- Ember.run(function(){
+test("attributeBindings should not fail if view has been destroyed", function() {
+ Ember.run(function() {
view = Ember.View.create({
attributeBindings: ['checked'],
checked: true
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
var error;
try {
- Ember.run(function(){
- Ember.changeProperties(function(){
+ Ember.run(function() {
+ Ember.changeProperties(function() {
view.set('checked', false);
view.destroy();
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/child_views_test.js | @@ -17,7 +17,7 @@
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
parentView.destroy();
childView.destroy();
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/class_name_bindings_test.js | @@ -30,7 +30,7 @@ test("should apply bound class names to the element", function() {
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -66,7 +66,7 @@ test("should add, remove, or change class names if changed after element is crea
})
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
set(view, 'priority', 'orange');
set(view, 'isUrgent', false);
@@ -97,53 +97,53 @@ test(":: class name syntax works with an empty true class", function() {
classNameBindings: ['isEnabled::not-enabled']
});
- Ember.run(function(){ view.createElement(); });
+ Ember.run(function() { view.createElement(); });
equal(view.$().attr('class'), 'ember-view not-enabled', "false class is rendered when property is false");
- Ember.run(function(){ view.set('isEnabled', true); });
+ Ember.run(function() { view.set('isEnabled', true); });
equal(view.$().attr('class'), 'ember-view', "no class is added when property is true and the class is empty");
});
-test("classNames should not be duplicated on rerender", function(){
- Ember.run(function(){
+test("classNames should not be duplicated on rerender", function() {
+ Ember.run(function() {
view = Ember.View.create({
classNameBindings: ['priority'],
priority: 'high'
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
equal(view.$().attr('class'), 'ember-view high');
- Ember.run(function(){
+ Ember.run(function() {
view.rerender();
});
equal(view.$().attr('class'), 'ember-view high');
});
-test("classNameBindings should work when the binding property is updated and the view has been removed of the DOM", function(){
- Ember.run(function(){
+test("classNameBindings should work when the binding property is updated and the view has been removed of the DOM", function() {
+ Ember.run(function() {
view = Ember.View.create({
classNameBindings: ['priority'],
priority: 'high'
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
equal(view.$().attr('class'), 'ember-view high');
- Ember.run(function(){
+ Ember.run(function() {
view.remove();
});
@@ -157,33 +157,33 @@ test("classNameBindings should work when the binding property is updated and the
});
-test("classNames removed by a classNameBindings observer should not re-appear on rerender", function(){
+test("classNames removed by a classNameBindings observer should not re-appear on rerender", function() {
view = Ember.View.create({
classNameBindings: ['isUrgent'],
isUrgent: true
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
equal(view.$().attr('class'), 'ember-view is-urgent');
- Ember.run(function(){
+ Ember.run(function() {
view.set('isUrgent', false);
});
equal(view.$().attr('class'), 'ember-view');
- Ember.run(function(){
+ Ember.run(function() {
view.rerender();
});
equal(view.$().attr('class'), 'ember-view');
});
-test("classNameBindings lifecycle test", function(){
- Ember.run(function(){
+test("classNameBindings lifecycle test", function() {
+ Ember.run(function() {
view = Ember.View.create({
classNameBindings: ['priority'],
priority: 'high'
@@ -192,35 +192,35 @@ test("classNameBindings lifecycle test", function(){
equal(Ember.isWatching(view, 'priority'), false);
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
equal(view.$().attr('class'), 'ember-view high');
equal(Ember.isWatching(view, 'priority'), true);
- Ember.run(function(){
+ Ember.run(function() {
view.remove();
view.set('priority', 'low');
});
equal(Ember.isWatching(view, 'priority'), false);
});
-test("classNameBindings should not fail if view has been removed", function(){
- Ember.run(function(){
+test("classNameBindings should not fail if view has been removed", function() {
+ Ember.run(function() {
view = Ember.View.create({
classNameBindings: ['priority'],
priority: 'high'
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
var error;
try {
- Ember.run(function(){
- Ember.changeProperties(function(){
+ Ember.run(function() {
+ Ember.changeProperties(function() {
view.set('priority', 'low');
view.remove();
});
@@ -231,20 +231,20 @@ test("classNameBindings should not fail if view has been removed", function(){
ok(!error, error);
});
-test("classNameBindings should not fail if view has been destroyed", function(){
- Ember.run(function(){
+test("classNameBindings should not fail if view has been destroyed", function() {
+ Ember.run(function() {
view = Ember.View.create({
classNameBindings: ['priority'],
priority: 'high'
});
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
var error;
try {
- Ember.run(function(){
- Ember.changeProperties(function(){
+ Ember.run(function() {
+ Ember.changeProperties(function() {
view.set('priority', 'low');
view.destroy();
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/create_element_test.js | @@ -13,7 +13,7 @@ test("returns the receiver", function() {
view = Ember.View.create();
- Ember.run(function(){
+ Ember.run(function() {
ret = view.createElement();
});
@@ -30,7 +30,7 @@ test("calls render and turns resultant string into element", function() {
});
equal(get(view, 'element'), null, 'precondition - has no element');
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -46,7 +46,7 @@ test("generated element include HTML from child views as well", function() {
childViews: [ Ember.View.create({ elementId: "foo" })]
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/destroy_element_test.js | @@ -36,7 +36,7 @@ test("if it has a element, calls willDestroyElement on receiver and child views
})]
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -56,7 +56,7 @@ test("returns receiver", function() {
var ret;
view = Ember.View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
ret = view.destroyElement();
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/destroy_test.js | @@ -9,7 +9,7 @@ test("should teardown viewName on parentView when childView is destroyed", funct
equal(get(parentView, viewName), childView, "Precond - child view was registered on parent");
- Ember.run(function(){
+ Ember.run(function() {
childView.destroy();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/is_visible_test.js | @@ -33,7 +33,7 @@ module("Ember.View#isVisible", {
teardown: function() {
if (view) {
- Ember.run(function(){ view.destroy(); });
+ Ember.run(function() { view.destroy(); });
}
}
});
@@ -89,7 +89,7 @@ test("should hide element if isVisible is false before element is created", func
});
test("view should be notified after isVisible is set to false and the element has been hidden", function() {
- Ember.run(function(){
+ Ember.run(function() {
view = View.create({ isVisible: false });
view.append();
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/jquery_test.js | @@ -15,7 +15,7 @@ module("Ember.View#$", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/layout_test.js | @@ -24,7 +24,7 @@ test("should call the function of the associated layout", function() {
templateName: 'template'
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -46,7 +46,7 @@ test("should call the function of the associated template with itself as the con
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -66,7 +66,7 @@ test("should fall back to defaultTemplate if neither template nor templateName a
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -82,7 +82,7 @@ test("should not use defaultLayout if layout is provided", function() {
});
view = View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -102,7 +102,7 @@ test("the template property is available to the layout template", function() {
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/nearest_of_type_test.js | @@ -41,7 +41,7 @@ module("Ember.View#nearest*", {
equal(child.nearestOfType(Mixin), parentView, "finds closest view in the hierarchy by class");
});
-test("nearestWithProperty should search immediate parent", function(){
+test("nearestWithProperty should search immediate parent", function() {
var childView;
view = Ember.View.create({ | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/remove_test.js | @@ -48,7 +48,7 @@ module("Ember.View#removeAllChildren", {
},
teardown: function() {
Ember.run(function() {
- childViews.forEach(function(v){ v.destroy(); });
+ childViews.forEach(function(v) { v.destroy(); });
view.destroy();
});
}
@@ -83,7 +83,7 @@ test("removes view from parent view", function() {
child = get(parentView, 'childViews').objectAt(0);
ok(get(child, 'parentView'), 'precond - has parentView');
- Ember.run(function(){
+ Ember.run(function() {
parentView.createElement();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/render_test.js | @@ -32,7 +32,7 @@ test("default implementation does not render child views", function() {
})
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
equal(rendered, 1, 'rendered the child once');
@@ -76,7 +76,7 @@ test("should invoke renderChildViews if layer is destroyed then re-rendered", fu
equal(parentRendered, 2);
equal(view.$('div').length, 1);
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
});
@@ -92,7 +92,7 @@ test("should render child views with a different tagName", function() {
})
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -102,7 +102,7 @@ test("should render child views with a different tagName", function() {
test("should add ember-view to views", function() {
view = Ember.View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -112,7 +112,7 @@ test("should add ember-view to views", function() {
test("should not add role attribute unless one is specified", function() {
view = Ember.View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/replace_in_test.js | @@ -8,7 +8,7 @@ module("Ember.View - replaceIn()", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
}
@@ -56,7 +56,7 @@ module("Ember.View - replaceIn() in a view hierarchy", {
},
teardown: function() {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/template_test.js | @@ -22,7 +22,7 @@ test("should call the function of the associated template", function() {
templateName: 'testTemplate'
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -43,7 +43,7 @@ test("should call the function of the associated template with itself as the con
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -63,7 +63,7 @@ test("should fall back to defaultTemplate if neither template nor templateName a
}
});
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -79,7 +79,7 @@ test("should not use defaultTemplate if template is provided", function() {
});
view = View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -98,7 +98,7 @@ test("should not use defaultTemplate if template is provided", function() {
});
view = View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -107,7 +107,7 @@ test("should not use defaultTemplate if template is provided", function() {
test("should render an empty element if no template is specified", function() {
view = Ember.View.create();
- Ember.run(function(){
+ Ember.run(function() {
view.createElement();
});
@@ -146,7 +146,7 @@ test("should provide a controller to the template if a controller is specified o
strictEqual(optionsDataKeywordsControllerForView, controller1, "passes the controller in the data");
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
@@ -173,7 +173,7 @@ test("should provide a controller to the template if a controller is specified o
strictEqual(optionsDataKeywordsControllerForView, controller1, "passes the controller in the data");
strictEqual(optionsDataKeywordsControllerForChildView, controller2, "passes the child view's controller in the data");
- Ember.run(function(){
+ Ember.run(function() {
parentView.destroy();
});
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-views/tests/views/view/view_lifecycle_test.js | @@ -9,7 +9,7 @@ module("views/view/view_lifecycle_test - pre-render", {
teardown: function() {
if (view) {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
}
@@ -92,7 +92,7 @@ module("views/view/view_lifecycle_test - in render", {
teardown: function() {
if (view) {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
}
@@ -154,7 +154,7 @@ test("rerender should throw inside a template", function() {
module("views/view/view_lifecycle_test - in DOM", {
teardown: function() {
if (view) {
- Ember.run(function(){
+ Ember.run(function() {
view.destroy();
});
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember/tests/helpers/link_to_test.js | @@ -124,7 +124,7 @@ test("The {{linkTo}} helper supports URL replacement", function() {
equal(replaceCount, 1, 'replaceURL should be called once');
});
-test("the {{linkTo}} helper doesn't add an href when the tagName isn't 'a'", function(){
+test("the {{linkTo}} helper doesn't add an href when the tagName isn't 'a'", function() {
Ember.TEMPLATES.index = Ember.Handlebars.compile("{{#linkTo 'about' id='about-link' tagName='div'}}About{{/linkTo}}");
Router.map(function() { | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember/tests/routing/basic_test.js | @@ -400,7 +400,7 @@ test("The Homepage with a computed context that does not get overridden", functi
});
App.HomeController = Ember.ArrayController.extend({
- content: Ember.computed(function(){
+ content: Ember.computed(function() {
return Ember.A([
"Monday through Friday: 9am to 5pm",
"Saturday: Noon to Midnight",
@@ -899,7 +899,7 @@ asyncTest("Events are triggered on the controller if a matching action name is i
);
var controller = Ember.Controller.extend({
- showStuff: function(context){
+ showStuff: function(context) {
ok (stateIsNotCalled, "an event on the state is not triggered");
deepEqual(context, { name: "Tom Dale" }, "an event with context is passed");
start();
@@ -1086,7 +1086,7 @@ test('navigating away triggers a url property change', function() {
var transition = handleURL("/");
- Ember.run(function(){
+ Ember.run(function() {
transition.then(function() {
equal(urlPropertyChangeCount, 2);
@@ -2100,26 +2100,26 @@ test("Route supports clearing outlet explicitly", function() {
App.PostsRoute = Ember.Route.extend({
events: {
- showModal: function(){
+ showModal: function() {
this.render('postsModal', {
into: 'application',
outlet: 'modal'
});
},
- hideModal: function(){
+ hideModal: function() {
this.disconnectOutlet({outlet: 'modal', parentView: 'application'});
}
}
});
App.PostsIndexRoute = Ember.Route.extend({
events: {
- showExtra: function(){
+ showExtra: function() {
this.render('postsExtra', {
into: 'posts/index'
});
},
- hideExtra: function(){
+ hideExtra: function() {
this.disconnectOutlet({parentView: 'posts/index'});
}
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/metamorph/lib/main.js | @@ -7,7 +7,7 @@ define("metamorph",
// Copyright: ©2011 My Company Inc. All rights reserved.
// ==========================================================================
- var K = function(){},
+ var K = function() {},
guid = 0,
document = this.document,
@@ -17,7 +17,7 @@ define("metamorph",
// Internet Explorer prior to 9 does not allow setting innerHTML if the first element
// is a "zero-scope" element. This problem can be worked around by making
// the first node an invisible text node. We, like Modernizr, use ­
- needsShy = document && (function(){
+ needsShy = document && (function() {
var testEl = document.createElement('div');
testEl.innerHTML = "<div></div>";
testEl.firstChild.innerHTML = "<script></script>"; | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/rsvp/lib/main.js | @@ -74,7 +74,7 @@ define("rsvp/async",
observer.observe(element, { attributes: true });
// Chrome Memory Leak: https://bugs.webkit.org/show_bug.cgi?id=93661
- window.addEventListener('unload', function(){
+ window.addEventListener('unload', function() {
observer.disconnect();
observer = null;
});
@@ -340,7 +340,7 @@ define("rsvp/promise",
return isFunction(x) || (typeof x === "object" && x !== null);
}
- function isFunction(x){
+ function isFunction(x) {
return typeof x === "function";
}
@@ -538,12 +538,12 @@ define("rsvp/resolve",
return typeof x === "function" || (typeof x === "object" && x !== null);
}
- function resolve(thenable){
- var promise = new Promise(function(resolve, reject){
+ function resolve(thenable) {
+ var promise = new Promise(function(resolve, reject) {
var then;
try {
- if ( objectOrFunction(thenable) ) {
+ if (objectOrFunction(thenable)) {
then = thenable.then;
if (typeof then === "function") { | true |
Other | emberjs | ember.js | 9a86b20c98fab82b8b6c583f0ae077bc4e7184ed.json | Fix typos in the inline testing package docs | packages/ember-testing/lib/helpers.js | @@ -189,7 +189,7 @@ helper('visit', visit);
* ```
*
* @method click
-* @param {String} selcetor jQuery selector for finding element on the DOM
+* @param {String} selector jQuery selector for finding element on the DOM
* @returns {RSVP.Promise}
*/
helper('click', click);
@@ -205,8 +205,8 @@ helper('click', click);
* });
* ```
*
-* @method click
-* @param {String} selcetor jQuery selector for finding element on the DOM
+* @method keyEvent
+* @param {String} selector jQuery selector for finding element on the DOM
* @param {String} the type of key event, e.g. `keypress`, `keydown`, `keyup`
* @param {Number} the keyCode of the simulated key event
* @returns {RSVP.Promise} | true |
Other | emberjs | ember.js | 9a86b20c98fab82b8b6c583f0ae077bc4e7184ed.json | Fix typos in the inline testing package docs | packages/ember-testing/lib/test.js | @@ -22,9 +22,9 @@ Ember.Test = {
For example:
```javascript
- Ember.Test.registerHelper('boot', function(app)) {
+ Ember.Test.registerHelper('boot', function(app) {
Ember.run(app, app.deferReadiness);
- }
+ });
```
This helper can later be called without arguments | true |
Other | emberjs | ember.js | 687ef9e408b73eb0b414262ed0d8c6b2f3557484.json | update jshint to include QUnit | .jshintrc | @@ -1,5 +1,6 @@
{
"predef": [
+ "QUnit",
"define",
"console",
"Ember", | false |
Other | emberjs | ember.js | 0b966fd1628f107f24cf7b545568e309c0caf346.json | remove un-needed context preservation | packages/ember-routing/lib/system/router.js | @@ -86,11 +86,7 @@ Ember.Router = Ember.Object.extend({
handleURL: function(url) {
scheduleLoadingStateEntry(this);
- var self = this;
-
- return this.router.handleURL(url).then(function() {
- transitionCompleted(self);
- });
+ return this.router.handleURL(url).then(transitionCompleted);
},
transitionTo: function() {
@@ -259,9 +255,7 @@ function doTransition(router, method, args) {
scheduleLoadingStateEntry(router);
var transitionPromise = router.router[method].apply(router.router, args);
- transitionPromise.then(function() {
- transitionCompleted(router);
- });
+ transitionPromise.then(transitionCompleted);
// We want to return the configurable promise object
// so that callers of this function can use `.method()` on it,
@@ -295,7 +289,8 @@ function exitLoadingState(router) {
router._loadingStateActive = false;
}
-function transitionCompleted(router) {
+function transitionCompleted(route) {
+ var router = route.router;
router.notifyPropertyChange('url');
exitLoadingState(router);
} | false |
Other | emberjs | ember.js | 1122abef59a1f957ab5f838029b5731a869b5a99.json | update basic tests
- add handleURL helper
- handleURL helper brings its own runloop
- assert handleURL is either fulfilled or rejected
- handle previously un-handled handleURL promise rejections | packages/ember-application/tests/system/logging_test.js | @@ -42,14 +42,20 @@ module("Ember.Application – logging of generated classes", {
function visit(path) {
stop();
- var promise = new Ember.RSVP.Promise(function(resolve, reject){
- var router = App.__container__.lookup('router:main');
-
- Ember.run(App, 'handleURL', path);
- Ember.run(router, router.location.setURL, path);
-
- Ember.run(resolve);
- start();
+ var promise = Ember.run(function(){
+ return new Ember.RSVP.Promise(function(resolve, reject){
+ var router = App.__container__.lookup('router:main');
+
+ resolve(router.handleURL(path).then(function(value){
+ start();
+ ok(true, 'visited: `' + path + '`');
+ return value;
+ }, function(reason) {
+ start();
+ ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));
+ throw reason;
+ }));
+ });
});
return { | true |
Other | emberjs | ember.js | 1122abef59a1f957ab5f838029b5731a869b5a99.json | update basic tests
- add handleURL helper
- handleURL helper brings its own runloop
- assert handleURL is either fulfilled or rejected
- handle previously un-handled handleURL promise rejections | packages/ember/tests/routing/basic_test.js | @@ -10,6 +10,40 @@ function compile(string) {
return Ember.Handlebars.compile(string);
}
+function handleURL(path) {
+ return Ember.run(function() {
+ return router.handleURL(path).then(function(value) {
+ ok(true, 'url: `' + path + '` was handled');
+ return value;
+ }, function(reason) {
+ ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));
+ throw reason;
+ });
+ });
+}
+
+function handleURLAborts(path) {
+ Ember.run(function() {
+ router.handleURL(path).then(function(value) {
+ ok(false, 'url: `' + path + '` was NOT to be handled');
+ }, function(reason) {
+ ok(reason && reason.message === "TransitionAborted", 'url: `' + path + '` was to be aborted');
+ });
+ });
+}
+
+
+
+function handleURLRejectsWith(path, expectedReason) {
+ Ember.run(function() {
+ router.handleURL(path).then(function(value) {
+ ok(false, 'expected handleURLing: `' + path + '` to fail');
+ }, function(reason) {
+ equal(expectedReason, reason);
+ });
+ });
+}
+
module("Basic Routing", {
setup: function() {
Ember.run(function() {
@@ -67,9 +101,7 @@ test("The Homepage", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(currentPath, 'home');
equal(Ember.$('h3:contains(Hours)', '#qunit-fixture').length, 1, "The home template was rendered");
@@ -106,17 +138,12 @@ test("The Home page and the Camelot page with multiple Router.map calls", functi
bootApplication();
- Ember.run(function() {
- router.handleURL("/camelot");
- });
+ handleURL("/camelot");
equal(currentPath, 'camelot');
equal(Ember.$('h3:contains(silly)', '#qunit-fixture').length, 1, "The camelot template was rendered");
-
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL("/");
equal(currentPath, 'home');
equal(Ember.$('h3:contains(Hours)', '#qunit-fixture').length, 1, "The home template was rendered");
@@ -136,15 +163,11 @@ test("The Homepage register as activeView", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
ok(router._lookupActiveView('home'), '`home` active view is connected');
- Ember.run(function() {
- router.handleURL("/homepage");
- });
+ handleURL('/homepage');
ok(router._lookupActiveView('homepage'), '`homepage` active view is connected');
equal(router._lookupActiveView('home'), undefined, '`home` active view is disconnected');
@@ -163,9 +186,7 @@ test("The Homepage with explicit template name in renderTemplate", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('h3:contains(Megatroll)', '#qunit-fixture').length, 1, "The homepage template was rendered");
});
@@ -187,9 +208,7 @@ test("An alternate template will pull in an alternate controller", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, "The homepage template was rendered");
});
@@ -211,9 +230,7 @@ test("The template will pull in an alternate controller via key/value", function
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('h3:contains(Megatroll) + p:contains(Comes from home.)', '#qunit-fixture').length, 1, "The homepage template was rendered from data from the HomeController");
});
@@ -235,9 +252,7 @@ test("The Homepage with explicit template name in renderTemplate and controller"
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, "The homepage template was rendered");
});
@@ -261,9 +276,7 @@ test("Renders correct view with slash notation", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('p:contains(Home/Page)', '#qunit-fixture').length, 1, "The homepage template was rendered");
});
@@ -285,9 +298,7 @@ test('render does not replace templateName if user provided', function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('p', '#qunit-fixture').text(), "THIS IS THE REAL HOME", "The homepage template was rendered");
});
@@ -315,9 +326,7 @@ test("The Homepage with a `setupController` hook", function() {
container.register('controller:home', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), "Sunday: Noon to 6pm", "The template was rendered with the hours context");
});
@@ -380,9 +389,7 @@ test("The Homepage with a `setupController` hook modifying other controllers", f
container.register('controller:home', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), "Sunday: Noon to 6pm", "The template was rendered with the hours context");
});
@@ -408,9 +415,7 @@ test("The Homepage with a computed context that does not get overridden", functi
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), "Sunday: Noon to 6pm", "The template was rendered with the context intact");
});
@@ -444,9 +449,7 @@ test("The Homepage getting its controller context via model", function() {
container.register('controller:home', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), "Sunday: Noon to 6pm", "The template was rendered with the hours context");
});
@@ -477,9 +480,7 @@ test("The Specials Page getting its controller context by deserializing the para
container.register('controller:special', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURL("/specials/1");
equal(Ember.$('p', '#qunit-fixture').text(), "1", "The model was used to render the template");
});
@@ -491,11 +492,13 @@ test("The Specials Page defaults to looking models up via `find`", function() {
});
App.MenuItem = Ember.Object.extend();
- App.MenuItem.find = function(id) {
- return Ember.Object.create({
- id: id
- });
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ return App.MenuItem.create({
+ id: id
+ });
+ }
+ });
App.SpecialRoute = Ember.Route.extend({
setupController: function(controller, model) {
@@ -511,9 +514,7 @@ test("The Specials Page defaults to looking models up via `find`", function() {
container.register('controller:special', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURL("/specials/1");
equal(Ember.$('p', '#qunit-fixture').text(), "1", "The model was used to render the template");
});
@@ -527,10 +528,15 @@ test("The Special Page returning a promise puts the app into a loading state unt
var menuItem;
App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = App.MenuItem.create({ id: id });
- return menuItem;
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ menuItem = App.MenuItem.create({
+ id: id
+ });
+
+ return menuItem;
+ }
+ });
App.LoadingRoute = Ember.Route.extend({
@@ -554,9 +560,7 @@ test("The Special Page returning a promise puts the app into a loading state unt
container.register('controller:special', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURL("/specials/1");
equal(Ember.$('p', '#qunit-fixture').text(), "LOADING!", "The app is in the loading state");
@@ -573,13 +577,12 @@ test("The loading state doesn't get entered for promises that resolve on the sam
this.resource("special", { path: "/specials/:menu_item_id" });
});
- var menuItem;
-
- App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = { id: 1 };
- return menuItem;
- };
+ App.MenuItem = Ember.Object.extend();
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ return { id: id };
+ }
+ });
App.LoadingRoute = Ember.Route.extend({
enter: function() {
@@ -605,9 +608,7 @@ test("The loading state doesn't get entered for promises that resolve on the sam
container.register('controller:special', Ember.Controller.extend());
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURL("/specials/1");
equal(Ember.$('p', '#qunit-fixture').text(), "1", "The app is now in the specials state");
});
@@ -621,13 +622,13 @@ asyncTest("The Special page returning an error fires the error hook on SpecialRo
var menuItem;
App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = App.MenuItem.create({ id: id });
-
- Ember.run.later(function() { menuItem.resolve(menuItem); }, 1);
-
- return menuItem;
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ menuItem = App.MenuItem.create({ id: id });
+ Ember.run.later(function() { menuItem.resolve(menuItem); }, 1);
+ return menuItem;
+ }
+ });
App.SpecialRoute = Ember.Route.extend({
setup: function() {
@@ -643,10 +644,7 @@ asyncTest("The Special page returning an error fires the error hook on SpecialRo
bootApplication();
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
-
+ handleURLRejectsWith('/specials/1', 'Setup error');
});
asyncTest("The Special page returning an error invokes SpecialRoute's error handler", function() {
@@ -658,13 +656,15 @@ asyncTest("The Special page returning an error invokes SpecialRoute's error hand
var menuItem;
App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = App.MenuItem.create({ id: id });
- Ember.run.later(function() {
- menuItem.resolve(menuItem);
- }, 1);
- return menuItem;
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ menuItem = App.MenuItem.create({ id: id });
+ Ember.run.later(function() {
+ menuItem.resolve(menuItem);
+ }, 1);
+ return menuItem;
+ }
+ });
App.SpecialRoute = Ember.Route.extend({
setup: function() {
@@ -680,9 +680,7 @@ asyncTest("The Special page returning an error invokes SpecialRoute's error hand
bootApplication();
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURLRejectsWith('/specials/1', 'Setup error');
});
asyncTest("ApplicationRoute's default error handler can be overridden", function() {
@@ -694,13 +692,15 @@ asyncTest("ApplicationRoute's default error handler can be overridden", function
var menuItem;
App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = App.MenuItem.create({ id: id });
- Ember.run.later(function() {
- menuItem.resolve(menuItem);
- }, 1);
- return menuItem;
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ menuItem = App.MenuItem.create({ id: id });
+ Ember.run.later(function() {
+ menuItem.resolve(menuItem);
+ }, 1);
+ return menuItem;
+ }
+ });
App.ApplicationRoute = Ember.Route.extend({
events: {
@@ -719,14 +719,11 @@ asyncTest("ApplicationRoute's default error handler can be overridden", function
bootApplication();
- Ember.run(function() {
- router.handleURL("/specials/1");
- });
+ handleURLRejectsWith("/specials/1", "Setup error");
});
asyncTest("Moving from one page to another triggers the correct callbacks", function() {
-
- expect(2);
+ expect(3);
Router.map(function() {
this.route("home", { path: "/" });
@@ -753,8 +750,10 @@ asyncTest("Moving from one page to another triggers the correct callbacks", func
container.register('controller:special', Ember.Controller.extend());
+ var transition = handleURL('/');
+
Ember.run(function() {
- router.handleURL("/").then(function() {
+ transition.then(function() {
equal(Ember.$('h3', '#qunit-fixture').text(), "Home", "The app is now in the initial state");
var promiseContext = App.MenuItem.create({ id: 1 });
@@ -788,10 +787,12 @@ asyncTest("Nested callbacks are not exited when moving to siblings", function()
var menuItem;
App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);
- App.MenuItem.find = function(id) {
- menuItem = App.MenuItem.create({ id: id });
- return menuItem;
- };
+ App.MenuItem.reopenClass({
+ find: function(id) {
+ menuItem = App.MenuItem.create({ id: id });
+ return menuItem;
+ }
+ });
App.LoadingRoute = Ember.Route.extend({
@@ -841,9 +842,7 @@ asyncTest("Nested callbacks are not exited when moving to siblings", function()
var rootSetup = 0, rootRender = 0, rootModel = 0, rootSerialize = 0;
- Ember.run(function() {
- bootApplication();
- });
+ bootApplication();
container.register('controller:special', Ember.Controller.extend());
@@ -856,7 +855,6 @@ asyncTest("Nested callbacks are not exited when moving to siblings", function()
router = container.lookup('router:main');
Ember.run(function() {
-
var menuItem = App.MenuItem.create({ id: 1 });
Ember.run.later(function() { menuItem.resolve(menuItem); }, 1);
@@ -870,7 +868,7 @@ asyncTest("Nested callbacks are not exited when moving to siblings", function()
deepEqual(router.location.path, '/specials/1');
equal(currentPath, 'root.special');
-
+
start();
});
});
@@ -912,10 +910,7 @@ asyncTest("Events are triggered on the controller if a matching action name is i
bootApplication();
-
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
var actionId = Ember.$("#qunit-fixture a").data("ember-action");
var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];
@@ -956,9 +951,7 @@ asyncTest("Events are triggered on the current state", function() {
//var controller = router._container.controller.home = Ember.Controller.create();
//controller.target = router;
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
var actionId = Ember.$("#qunit-fixture a").data("ember-action");
var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];
@@ -1059,9 +1052,7 @@ test("transitioning multiple times in a single run loop only sets the URL once",
set(this, 'path', path);
};
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(urlSetCount, 0);
@@ -1093,8 +1084,10 @@ test('navigating away triggers a url property change', function() {
equal(urlPropertyChangeCount, 0);
- Ember.run(function() {
- router.handleURL("/").then(function() {
+ var transition = handleURL("/");
+
+ Ember.run(function(){
+ transition.then(function() {
equal(urlPropertyChangeCount, 2);
// Trigger the callback that would otherwise be triggered
@@ -1135,9 +1128,7 @@ test("using replaceWith calls location.replaceURL if available", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(setCount, 0);
equal(replaceCount, 0);
@@ -1170,9 +1161,7 @@ test("using replaceWith calls setURL if location.replaceURL is not defined", fun
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL('/');
equal(setCount, 0);
@@ -1185,7 +1174,7 @@ test("using replaceWith calls setURL if location.replaceURL is not defined", fun
});
test("It is possible to get the model from a parent route", function() {
- expect(6);
+ expect(9);
Router.map(function() {
this.resource("the_post", { path: "/posts/:post_id" }, function() {
@@ -1217,20 +1206,14 @@ test("It is possible to get the model from a parent route", function() {
bootApplication();
- Ember.run(function() {
- currentPost = post1;
- router.handleURL("/posts/1/comments");
- });
+ currentPost = post1;
+ handleURL("/posts/1/comments");
- Ember.run(function() {
- currentPost = post2;
- router.handleURL("/posts/2/comments");
- });
+ currentPost = post2;
+ handleURL("/posts/2/comments");
- Ember.run(function() {
- currentPost = post3;
- router.handleURL("/posts/3/comments");
- });
+ currentPost = post3;
+ handleURL("/posts/3/comments");
});
test("A redirection hook is provided", function() {
@@ -1263,7 +1246,7 @@ test("A redirection hook is provided", function() {
});
test("Redirecting from the middle of a route aborts the remainder of the routes", function() {
- expect(2);
+ expect(3);
Router.map(function() {
this.route("home");
@@ -1291,16 +1274,14 @@ test("Redirecting from the middle of a route aborts the remainder of the routes"
bootApplication();
- Ember.run(function() {
- router.handleURL("/foo/bar/baz");
- });
+ handleURLAborts("/foo/bar/baz");
equal(router.container.lookup('controller:application').get('currentPath'), 'home');
equal(router.get('location').getURL(), "/home");
});
test("Redirecting to the current target in the middle of a route does not abort initial routing", function() {
- expect(4);
+ expect(5);
Router.map(function() {
this.route("home");
@@ -1332,17 +1313,15 @@ test("Redirecting to the current target in the middle of a route does not abort
bootApplication();
- Ember.run(function() {
- router.handleURL("/foo/bar/baz");
- });
+ handleURL("/foo/bar/baz");
equal(router.container.lookup('controller:application').get('currentPath'), 'foo.bar.baz');
equal(successCount, 1, 'transitionTo success handler was called once');
});
test("Redirecting to the current target with a different context aborts the remainder of the routes", function() {
- expect(3);
+ expect(4);
Router.map(function() {
this.route("home");
@@ -1379,9 +1358,7 @@ test("Redirecting to the current target with a different context aborts the rema
bootApplication();
- Ember.run(function() {
- router.handleURL("/foo/bar/1/baz");
- });
+ handleURLAborts("/foo/bar/1/baz");
equal(router.container.lookup('controller:application').get('currentPath'), 'foo.bar.baz');
equal(router.get('location').getURL(), "/foo/bar/2/baz");
@@ -1409,9 +1386,7 @@ test("Transitioning from a parent event does not prevent currentPath from being
var applicationController = router.container.lookup('controller:application');
- Ember.run(function() {
- router.handleURL("/foo/bar/baz");
- });
+ handleURL("/foo/bar/baz");
equal(applicationController.get('currentPath'), 'foo.bar.baz');
@@ -1424,7 +1399,7 @@ test("Transitioning from a parent event does not prevent currentPath from being
});
test("Generated names can be customized when providing routes with dot notation", function() {
- expect(3);
+ expect(4);
Ember.TEMPLATES.index = compile("<div>Index</div>");
Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>");
@@ -1464,9 +1439,7 @@ test("Generated names can be customized when providing routes with dot notation"
bootApplication();
- Ember.run(function() {
- router.handleURL("/top/middle/bottom");
- });
+ handleURL("/top/middle/bottom");
equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "BarBazBottom!", "The templates were rendered into their appropriate parents");
});
@@ -1488,9 +1461,7 @@ test("Child routes render into their parent route's template by default", functi
bootApplication();
- Ember.run(function() {
- router.handleURL("/top/middle/bottom");
- });
+ handleURL("/top/middle/bottom");
equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "Bottom!", "The templates were rendered into their appropriate parents");
});
@@ -1518,9 +1489,7 @@ test("Child routes render into specified template", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/top/middle/bottom");
- });
+ handleURL("/top/middle/bottom");
equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').length, 0, "should not render into the middle template");
equal(Ember.$('.main .middle > p', '#qunit-fixture').text(), "Bottom!", "The template was rendered into the top template");
@@ -1543,9 +1512,7 @@ test("Rendering into specified template with slash notation", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL("/");
equal(Ember.$('#qunit-fixture:contains(profile details!)').length, 1, "The templates were rendered");
});
@@ -1603,9 +1570,7 @@ test("Parent route context change", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts/1");
- });
+ handleURL("/posts/1");
Ember.run(function() {
router.send('editPost');
@@ -1760,9 +1725,7 @@ test("Only use route rendered into main outlet for default into property on chil
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts");
- });
+ handleURL("/posts");
equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, "The posts/menu template was rendered");
equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, "The posts/index template was rendered");
@@ -1786,9 +1749,7 @@ test("Generating a URL should not affect currentModel", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts/1");
- });
+ handleURL("/posts/1");
var route = container.lookup('route:post');
equal(route.modelFor('post'), posts[1]);
@@ -1811,9 +1772,7 @@ test("Generated route should be an instance of App.Route if provided", function(
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts");
- });
+ handleURL("/posts");
generatedRoute = container.lookup('route:posts');
@@ -1859,9 +1818,7 @@ test("Application template does not duplicate when re-rendered", function() {
bootApplication();
// should cause application template to re-render
- Ember.run(function() {
- router.handleURL('/posts');
- });
+ handleURL('/posts');
equal(Ember.$('h3:contains(I Render Once)').size(), 1);
});
@@ -1910,16 +1867,12 @@ test("The template is not re-rendered when the route's context changes", functio
bootApplication();
- Ember.run(function() {
- router.handleURL("/page/first");
- });
+ handleURL("/page/first");
equal(Ember.$('p', '#qunit-fixture').text(), "first");
equal(insertionCount, 1);
- Ember.run(function() {
- router.handleURL("/page/second");
- });
+ handleURL("/page/second");
equal(Ember.$('p', '#qunit-fixture').text(), "second");
equal(insertionCount, 1, "view should have inserted only once");
@@ -1955,7 +1908,7 @@ test("The template is not re-rendered when two routes present the exact same tem
App.SecondRoute = App.SharedRoute.extend();
App.ThirdRoute = App.SharedRoute.extend();
App.FourthRoute = App.SharedRoute.extend();
-
+
App.SharedController = Ember.Controller.extend();
var insertionCount = 0;
@@ -1976,17 +1929,13 @@ test("The template is not re-rendered when two routes present the exact same tem
bootApplication();
- Ember.run(function() {
- router.handleURL("/first");
- });
+ handleURL("/first");
equal(Ember.$('p', '#qunit-fixture').text(), "This is the first message");
equal(insertionCount, 1);
// Transition by URL
- Ember.run(function() {
- router.handleURL("/second");
- });
+ handleURL("/second");
equal(Ember.$('p', '#qunit-fixture').text(), "This is the second message");
equal(insertionCount, 1, "view should have inserted only once");
@@ -1998,15 +1947,13 @@ test("The template is not re-rendered when two routes present the exact same tem
equal(Ember.$('p', '#qunit-fixture').text(), "This is the third message");
equal(insertionCount, 1, "view should still have inserted only once");
-
+
// Lastly transition to a different view, with the same controller and template
- Ember.run(function() {
- router.handleURL("/fourth");
- });
+ handleURL("/fourth");
equal(Ember.$('p', '#qunit-fixture').text(), "This is the fourth message");
equal(insertionCount, 2, "view should have inserted a second time");
-
+
});
test("ApplicationRoute with model does not proxy the currentPath", function() {
@@ -2025,9 +1972,7 @@ test("ApplicationRoute with model does not proxy the currentPath", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/");
- });
+ handleURL("/");
equal(currentPath, 'index', 'currentPath is index');
equal('currentPath' in model, false, 'should have defined currentPath on controller');
@@ -2086,7 +2031,7 @@ test("Route should tear down multiple outlets", function() {
tagName: 'p',
classNames: ['posts-index']
});
-
+
App.PostsFooterView = Ember.View.extend({
tagName: 'div',
templateName: 'posts/footer',
@@ -2099,9 +2044,9 @@ test("Route should tear down multiple outlets", function() {
into: 'application',
outlet: 'menu'
});
-
+
this.render();
-
+
this.render('postsFooter', {
into: 'application',
outlet: 'footer'
@@ -2111,22 +2056,18 @@ test("Route should tear down multiple outlets", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts");
- });
+ handleURL('/posts');
equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, "The posts/menu template was rendered");
equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, "The posts/index template was rendered");
equal(Ember.$('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 1, "The posts/footer template was rendered");
- Ember.run(function() {
- router.handleURL("/users");
- });
-
+ handleURL('/users');
+
equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 0, "The posts/menu template was removed");
- equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, "The posts/index template was removed");
+ equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, "The posts/index template was removed");
equal(Ember.$('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 0, "The posts/footer template was removed");
-
+
});
@@ -2186,9 +2127,8 @@ test("Route supports clearing outlet explicitly", function() {
bootApplication();
- Ember.run(function() {
- router.handleURL("/posts");
- });
+ handleURL('/posts');
+
equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, "The posts/index template was rendered");
Ember.run(function() {
router.send('showModal');
@@ -2207,13 +2147,10 @@ test("Route supports clearing outlet explicitly", function() {
});
equal(Ember.$('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, "The posts/extra template was removed");
- Ember.run(function() {
- router.handleURL("/users");
- });
+ handleURL('/users');
equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, "The posts/index template was removed");
equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, "The posts/modal template was removed");
equal(Ember.$('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, "The posts/extra template was removed");
});
- | true |
Other | emberjs | ember.js | 1629e12a0c30ba11b4bdeb3280cd36698e9caf6b.json | Fix typo in core_object.js | packages/ember-runtime/lib/system/core_object.js | @@ -6,8 +6,8 @@ require('ember-runtime/system/namespace');
*/
-// NOTE: this object should never be included directly. Instead use Ember.
-// Ember.Object. We only define this separately so that Ember.Set can depend on it
+// NOTE: this object should never be included directly. Instead use `Ember.Object`.
+// We only define this separately so that `Ember.Set` can depend on it.
var set = Ember.set, get = Ember.get, | false |
Other | emberjs | ember.js | f20bf0599d8185aaa7d154081d0b41336d7d85e2.json | Improve Ember.Logger setup - Fixes #2962 | packages/ember-metal/lib/core.js | @@ -152,16 +152,19 @@ Ember.uuid = 0;
//
function consoleMethod(name) {
- if (imports.console && imports.console[name]) {
+ var console = imports.console,
+ method = typeof console === 'object' ? console[name] : null;
+
+ if (method) {
// Older IE doesn't support apply, but Chrome needs it
- if (imports.console[name].apply) {
+ if (method.apply) {
return function() {
- imports.console[name].apply(imports.console, arguments);
+ method.apply(console, arguments);
};
} else {
return function() {
var message = Array.prototype.join.call(arguments, ', ');
- imports.console[name](message);
+ method(message);
};
}
} | false |
Other | emberjs | ember.js | e08d638d4033457d3c21f2458ff64e7714bd9dbd.json | add resolveModel to the default resolver | packages/ember-application/lib/system/resolver.js | @@ -71,6 +71,7 @@ var get = Ember.get,
'view:blog/post' //=> Blog.PostView
'view:basic' //=> Ember.View
'foo:post' //=> App.PostFoo
+ 'model:post' //=> App.Post
```
@class DefaultResolver
@@ -191,6 +192,17 @@ Ember.DefaultResolver = Ember.Object.extend({
this.useRouterNaming(parsedName);
return this.resolveOther(parsedName);
},
+
+ /**
+ @protected
+ @method resolveModel
+ */
+ resolveModel: function(parsedName){
+ var className = classify(parsedName.name),
+ factory = get(parsedName.root, className);
+
+ if (factory) { return factory; }
+ },
/**
Look up the specified object (from parsedName) on the appropriate
namespace (usually on the Application) | true |
Other | emberjs | ember.js | e08d638d4033457d3c21f2458ff64e7714bd9dbd.json | add resolveModel to the default resolver | packages/ember-application/tests/system/dependency_injection/default_resolver_test.js | @@ -46,3 +46,7 @@ test('the default resolver looks up arbitrary types on the namespace', function(
equal(locator.resolve('manager:foo'), application.FooManager, "looks up FooManager on application");
});
+test("the default resolver resolves models on the namespace", function() {
+ application.Post = Ember.Object.extend({});
+ equal(locator.lookupFactory('model:post'), application.Post, "looks up Post model on application");
+}); | true |
Other | emberjs | ember.js | ba042244de33a172e4d7bf2a3f486f5746bc8475.json | fix deprecation warning | packages/ember-handlebars/tests/handlebars_test.js | @@ -712,7 +712,8 @@ test("edge case: child conditional should not render children if parent conditio
test("Template views return throw if their template cannot be found", function() {
view = Ember.View.create({
- templateName: 'cantBeFound'
+ templateName: 'cantBeFound',
+ container: { lookup: function(){ }}
});
expectAssertion(function() { | false |
Other | emberjs | ember.js | 1af8c0771a3ed3df1dfea428bdc132ac64bf5c79.json | Specify controller of a route via controllerName
This commit adds the possibility to specify the controller a route shall
use via a `controllerName` property.
Given the following app:
```
App.Router.map(function() {
this.resource('team', function() {
this.route('overview');
this.route('detail');
});
});
App.TeamController = Ember.ObjectController.extend({ ... });
App.TeamOverviewRoute = Ember.Route.extend({ controllerName: 'team' });
```
The controller in the `team/overview` template is the `App.TeamController`
instead of the generated `App.TeamOverviewController`. Since the
`controllerName` isn't set on the `App.TeamDetailRoute`, in this
template the generated `App.TeamDetailController` is used. | packages/ember-routing/lib/system/route.js | @@ -214,7 +214,7 @@ Ember.Route = Ember.Object.extend({
@method setup
*/
setup: function(context) {
- var controller = this.controllerFor(this.routeName, context);
+ var controller = this.controllerFor(this.controllerName || this.routeName, context);
// Assign the route's controller so that it can more easily be
// referenced in event handlers | true |
Other | emberjs | ember.js | 1af8c0771a3ed3df1dfea428bdc132ac64bf5c79.json | Specify controller of a route via controllerName
This commit adds the possibility to specify the controller a route shall
use via a `controllerName` property.
Given the following app:
```
App.Router.map(function() {
this.resource('team', function() {
this.route('overview');
this.route('detail');
});
});
App.TeamController = Ember.ObjectController.extend({ ... });
App.TeamOverviewRoute = Ember.Route.extend({ controllerName: 'team' });
```
The controller in the `team/overview` template is the `App.TeamController`
instead of the generated `App.TeamOverviewController`. Since the
`controllerName` isn't set on the `App.TeamDetailRoute`, in this
template the generated `App.TeamDetailController` is used. | packages/ember/tests/routing/basic_test.js | @@ -341,6 +341,22 @@ test("The route controller is still set when overriding the setupController hook
deepEqual(container.lookup('route:home').controller, container.lookup('controller:home'), "route controller is the home controller");
});
+test("The route controller can be specified via controllerName", function() {
+ Router.map(function() {
+ this.route("home", { path: "/" });
+ });
+
+ App.HomeRoute = Ember.Route.extend({
+ controllerName: 'myController'
+ });
+
+ container.register('controller:myController', Ember.Controller.extend());
+
+ bootApplication();
+
+ deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), "route controller is set by controllerName");
+});
+
test("The Homepage with a `setupController` hook modifying other controllers", function() {
Router.map(function() {
this.route("home", { path: "/" }); | true |
Other | emberjs | ember.js | 0a7420c63b59d22f6a89c5f3967fac106f743a78.json | Remove property for compatibility
This is the compatibility for SproutCore.
But now it seems no longer needed. | packages/ember-runtime/lib/mixins/enumerable.js | @@ -72,9 +72,6 @@ function iter(key, value) {
*/
Ember.Enumerable = Ember.Mixin.create({
- // compatibility
- isEnumerable: true,
-
/**
Implement this method to make your class enumerable.
| false |
Other | emberjs | ember.js | 000f47f75c14aed055f5c2e1b5ccecfa37d43755.json | Fix failing test in IE | packages/ember-testing/tests/helpers_test.js | @@ -178,6 +178,8 @@ test("`click` triggers appropriate events in order", function() {
['mousedown', 'focusin', 'mouseup', 'click'],
'fires focus events on textareas');
}).then(function() {
+ // In IE (< 8), the change event only fires when the value changes before element focused.
+ Ember.$('.index-view input[type=checkbox]').focus();
events = [];
return click('.index-view input[type=checkbox]');
}).then(function() { | false |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-handlebars/lib/controls/select.js | @@ -441,15 +441,15 @@ Ember.Select = Ember.View.extend(
groupedContent: Ember.computed(function() {
var groupPath = get(this, 'optionGroupPath');
- var groupedContent = Ember.A([]);
+ var groupedContent = Ember.A();
forEach(get(this, 'content'), function(item) {
var label = get(item, groupPath);
if (get(groupedContent, 'lastObject.label') !== label) {
groupedContent.pushObject({
label: label,
- content: Ember.A([])
+ content: Ember.A()
});
}
| true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-handlebars/tests/controls/select_test.js | @@ -725,7 +725,7 @@ test("upon content change with Array-like content, the DOM should reflect the se
sylvain = {id: 5, name: 'Sylvain'};
var proxy = Ember.ArrayProxy.create({
- content: Ember.A([]),
+ content: Ember.A(),
selectedOption: sylvain
});
| true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-handlebars/tests/helpers/each_test.js | @@ -370,7 +370,7 @@ test("it supports {{else}}", function() {
assertHTML(view, "onetwo");
Ember.run(function() {
- view.set('items', Ember.A([]));
+ view.set('items', Ember.A());
});
assertHTML(view, "Nothing"); | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-handlebars/tests/helpers/if_unless_test.js | @@ -80,7 +80,7 @@ test("The `if` helper updates if an object proxy gains or loses context", functi
test("The `if` helper updates if an array is empty or not", function() {
view = Ember.View.create({
- array: Ember.A([]),
+ array: Ember.A(),
template: compile('{{#if view.array}}Yep{{/if}}')
}); | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-handlebars/tests/helpers/yield_test.js | @@ -65,7 +65,7 @@ test("templates should yield to block, when the yield is embedded in a hierarchy
layout: Ember.Handlebars.compile('<div class="times">{{#each view.index}}{{yield}}{{/each}}</div>'),
n: null,
index: Ember.computed(function() {
- var n = Ember.get(this, 'n'), indexArray = Ember.A([]);
+ var n = Ember.get(this, 'n'), indexArray = Ember.A();
for (var i=0; i < n; i++) {
indexArray[i] = i;
} | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-runtime/lib/mixins/array.js | @@ -154,7 +154,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
@return {Array} New array with specified slice
*/
slice: function(beginIndex, endIndex) {
- var ret = Ember.A([]);
+ var ret = Ember.A();
var length = get(this, 'length') ;
if (isNone(beginIndex)) beginIndex = 0 ;
if (isNone(endIndex) || (endIndex > length)) endIndex = length ; | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-runtime/lib/mixins/enumerable.js | @@ -284,7 +284,7 @@ Ember.Enumerable = Ember.Mixin.create({
@return {Array} The mapped array.
*/
map: function(callback, target) {
- var ret = Ember.A([]);
+ var ret = Ember.A();
this.forEach(function(x, idx, i) {
ret[idx] = callback.call(target, x, idx,i);
});
@@ -334,7 +334,7 @@ Ember.Enumerable = Ember.Mixin.create({
@return {Array} A filtered array.
*/
filter: function(callback, target) {
- var ret = Ember.A([]);
+ var ret = Ember.A();
this.forEach(function(x, idx, i) {
if (callback.call(target, x, idx, i)) ret.push(x);
});
@@ -623,7 +623,7 @@ Ember.Enumerable = Ember.Mixin.create({
@return {Array} return values from calling invoke.
*/
invoke: function(methodName) {
- var args, ret = Ember.A([]);
+ var args, ret = Ember.A();
if (arguments.length>1) args = a_slice.call(arguments, 1);
this.forEach(function(x, idx) {
@@ -644,7 +644,7 @@ Ember.Enumerable = Ember.Mixin.create({
@return {Array} the enumerable as an array.
*/
toArray: function() {
- var ret = Ember.A([]);
+ var ret = Ember.A();
this.forEach(function(o, idx) { ret[idx] = o; });
return ret ;
},
@@ -680,7 +680,7 @@ Ember.Enumerable = Ember.Mixin.create({
*/
without: function(value) {
if (!this.contains(value)) return this; // nothing to do
- var ret = Ember.A([]);
+ var ret = Ember.A();
this.forEach(function(k) {
if (k !== value) ret[ret.length] = k;
}) ;
@@ -700,7 +700,7 @@ Ember.Enumerable = Ember.Mixin.create({
@return {Ember.Enumerable}
*/
uniq: function() {
- var ret = Ember.A([]);
+ var ret = Ember.A();
this.forEach(function(k){
if (a_indexOf(ret, k)<0) ret.push(k);
}); | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-runtime/tests/core/is_array_test.js | @@ -1,7 +1,7 @@
module("Ember Type Checking");
test("Ember.isArray" ,function(){
- var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A([]) });
+ var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A() });
equal(Ember.isArray(arrayProxy), true, "[]");
}); | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-runtime/tests/core/is_empty_test.js | @@ -1,7 +1,7 @@
module("Ember.isEmpty");
test("Ember.isEmpty", function() {
- var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A([]) });
+ var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A() });
equal(true, Ember.isEmpty(arrayProxy), "for an ArrayProxy that has empty content");
}); | true |
Other | emberjs | ember.js | a050008557631dce1049636f957abff7005d0542.json | Remove unnecessary array
To save code size and improve performance. | packages/ember-runtime/tests/system/array_proxy/content_update_test.js | @@ -11,7 +11,7 @@ test("The `contentArrayDidChange` method is invoked after `content` is updated."
var proxy, observerCalled = false;
proxy = Ember.ArrayProxy.createWithMixins({
- content: Ember.A([]),
+ content: Ember.A(),
arrangedContent: Ember.computed('content', function(key, value) {
// setup arrangedContent as a different object than content, | true |
Other | emberjs | ember.js | c2794b681e9daf504b56f5c53ac7e6679986c37b.json | Fix example code indent | packages/ember-states/lib/state_manager.js | @@ -565,10 +565,10 @@ var sendEvent = function(eventName, sendRecursiveArguments, isUnhandledPass) {
})
}),
stateTwo: Ember.State.create({
- anAction: function(manager, context){
- // will not be called below because it is
- // not a parent of the current state
- }
+ anAction: function(manager, context){
+ // will not be called below because it is
+ // not a parent of the current state
+ }
})
})
| false |
Other | emberjs | ember.js | 58fd8c71ea677cd4e1e97de5d50b105e9ec0d92d.json | Document the container | packages/container/lib/main.js | @@ -2,12 +2,43 @@ define("container",
[],
function() {
+ /**
+ A safe and simple inheriting object.
+
+ @class InheritingDict
+ */
function InheritingDict(parent) {
this.parent = parent;
this.dict = {};
}
InheritingDict.prototype = {
+
+ /**
+ @property parent
+ @type InheritingDict
+ @default null
+ */
+
+ parent: null,
+
+ /**
+ Object used to store the current nodes data.
+
+ @property dict
+ @type Object
+ @default Object
+ */
+ dict: null,
+
+ /**
+ Retrieve the value given a key, if the value is present at the current
+ level use it, otherwise walk up the parent hierarchy and try again. If
+ no matching key is found, return undefined.
+
+ @method get
+ @return {any}
+ */
get: function(key) {
var dict = this.dict;
@@ -20,10 +51,26 @@ define("container",
}
},
+ /**
+ Set the given value for the given key, at the current level.
+
+ @method set
+ @param {String} key
+ @param {Any} value
+ */
set: function(key, value) {
this.dict[key] = value;
},
+ /**
+ Check for the existence of given a key, if the key is present at the current
+ level return true, otherwise walk up the parent hierarchy and try again. If
+ no matching key is found, return false.
+
+ @method has
+ @param {String} key
+ @returns {Boolean}
+ */
has: function(key) {
var dict = this.dict;
@@ -38,6 +85,13 @@ define("container",
return false;
},
+ /**
+ Iterate and invoke a callback for each local key-value pair.
+
+ @method eachLocal
+ @param {Function} callback
+ @param {Object} binding
+ */
eachLocal: function(callback, binding) {
var dict = this.dict;
@@ -49,6 +103,11 @@ define("container",
}
};
+ /**
+ A lightweight container that helps to assemble and decouple components.
+
+ @class Container
+ */
function Container(parent) {
this.parent = parent;
this.children = [];
@@ -63,16 +122,115 @@ define("container",
}
Container.prototype = {
+
+ /**
+ @property parent
+ @type Container
+ @default null
+ */
+ parent: null,
+
+ /**
+ @property children
+ @type Array
+ @default []
+ */
+ children: null,
+
+ /**
+ @property resolver
+ @type function
+ */
+ resolver: null,
+
+ /**
+ @property registry
+ @type InheritingDict
+ */
+ registry: null,
+
+ /**
+ @property cache
+ @type InheritingDict
+ */
+ cache: null,
+
+ /**
+ @property typeInjections
+ @type InheritingDict
+ */
+ typeInjections: null,
+
+ /**
+ @property injections
+ @type Object
+ @default {}
+ */
+ injections: null,
+
+ /**
+ @private
+
+ @property _options
+ @type InheritingDict
+ @default null
+ */
+ _options: null,
+
+ /**
+ @private
+
+ @property _typeOptions
+ @type InheritingDict
+ */
+ _typeOptions: null,
+
+ /**
+ Returns a new child of the current container. These children are configured
+ to correctly inherit from the current container.
+
+ @method child
+ @returns {Container}
+ */
child: function() {
var container = new Container(this);
this.children.push(container);
return container;
},
+ /**
+ Sets a key-value pair on the current container. If a parent container,
+ has the same key, once set on a child, the parent and child will diverge
+ as expected.
+
+ @method set
+ @param {Object} obkect
+ @param {String} key
+ @param {any} value
+ */
set: function(object, key, value) {
object[key] = value;
},
+ /**
+ Registers a factory for later injection.
+
+ Example:
+
+ ```javascript
+ var container = new Container();
+
+ container.register('model:user', Person, {singleton: false });
+ container.register('fruit:favorite', Orange);
+ container.register('communication:main', Email, {singleton: false});
+ ```
+
+ @method register
+ @param {String} type
+ @param {String} name
+ @param {Function} factory
+ @param {Object} options
+ */
register: function(type, name, factory, options) {
var fullName;
@@ -91,14 +249,92 @@ define("container",
this._options.set(normalizedName, options || {});
},
+ /**
+ Given a fullName return the corresponding factory.
+
+ By default `resolve` will retreive the factory from
+ it's containers registry.
+
+ ```javascript
+ var container = new Container();
+ container.register('api:twitter', Twitter);
+
+ container.resolve('api:twitter') // => Twitter
+ ```
+
+ Optionally the container can be provided with a custom resolver.
+ If provided, `resolve` will first provide the custom resolver
+ the oppertunity to resolve the fullName, otherwise it will fallback
+ to the registry.
+
+ ```javascript
+ var container = new Container();
+ container.resolver = function(fullName) {
+ // lookup via the module system of choice
+ };
+
+ // the twitter factory is added to the module system
+ container.resolve('api:twitter') // => Twitter
+ ```
+
+ @method resolve
+ @param {String} fullName
+ @returns {Function} fullName's factory
+ */
resolve: function(fullName) {
return this.resolver(fullName) || this.registry.get(fullName);
},
+ /**
+ A hook to enable custom fullName normalization behaviour
+
+ @method normalize
+ @param {String} fullName
+ @return {string} normalized fullName
+ */
normalize: function(fullName) {
return fullName;
},
+ /**
+ Given a fullName return a corresponding instance.
+
+ The default behaviour is for lookup to return a singleton instance.
+ The singleton is scoped to the container, allowing multiple containers
+ to all have there own locally scoped singletons.
+
+ ```javascript
+ var container = new Container();
+ container.register('api:twitter', Twitter);
+
+ var twitter = container.lookup('api:twitter');
+
+ twitter instanceof Twitter; // => true
+
+ // by default the container will return singletons
+ twitter2 = container.lookup('api:twitter');
+ twitter instanceof Twitter; // => true
+
+ twitter === twitter2; //=> true
+ ```
+
+ If singletons are not wanted an optional flag can be provided at lookup.
+
+ ```javascript
+ var container = new Container();
+ container.register('api:twitter', Twitter);
+
+ var twitter = container.lookup('api:twitter', { singleton: false });
+ var twitter2 = container.lookup('api:twitter', { singleton: false });
+
+ twitter === twitter2; //=> false
+ ```
+
+ @method lookup
+ @param {String} fullName
+ @param {Object} options
+ @return {any}
+ */
lookup: function(fullName, options) {
fullName = this.normalize(fullName);
@@ -119,10 +355,25 @@ define("container",
return value;
},
+ /**
+ Given a fullName return the corresponding factory.
+
+ @method lookupFactory
+ @param {String} fullName
+ @return {any}
+ */
lookupFactory: function(fullName) {
return factoryFor(this, fullName);
},
+ /**
+ Given a fullName check if the container is aware of its factory
+ or singleton instance.
+
+ @method has
+ @param {String} fullName
+ @return {Boolean}
+ */
has: function(fullName) {
if (this.cache.has(fullName)) {
return true;
@@ -131,27 +382,144 @@ define("container",
return !!factoryFor(this, fullName);
},
+ /**
+ Allow registerying options for all factories of a type.
+
+ ```javascript
+ var container = new Container();
+
+ // if all of type `connection` must not be singletons
+ container.optionsForType('connection', { singleton: false });
+
+ container.register('connection:twitter', TwitterConnection);
+ container.register('connection:facebook', FacebookConnection);
+
+ var twitter = container.lookup('connection:twitter');
+ var twitter2 = container.lookup('connection:twitter');
+
+ twitter === twitter2; // => false
+
+ var facebook = container.lookup('connection:facebook');
+ var facebook2 = container.lookup('connection:facebook');
+
+ facebook === facebook2; // => false
+ ```
+
+ @method optionsForType
+ @param {String} type
+ @param {Object} options
+ */
optionsForType: function(type, options) {
if (this.parent) { illegalChildOperation('optionsForType'); }
this._typeOptions.set(type, options);
},
+ /**
+ @method options
+ @param {String} type
+ @param {Object} options
+ */
options: function(type, options) {
this.optionsForType(type, options);
},
+ /*
+ @private
+
+ Used only via `injection`.
+
+ Provides a specialized form of injection, specifically enabling
+ all objects of one type to be injected with a reference to another
+ object.
+
+ For example, provided each object of type `controller` needed a `router`.
+ one would do the following:
+
+ ```javascript
+ var container = new Container();
+
+ container.register('router:main', Router);
+ container.register('controller:user', UserController);
+ container.register('controller:post', PostController);
+
+ container.typeInjection('controller', 'router', 'router:main');
+
+ var user = container.lookup('controller:user');
+ var post = container.lookup('controller:post');
+
+ user.router instanceof Router; //=> true
+ post.router instanceof Router; //=> true
+
+ // both controllers share the same router
+ user.router === post.router; //=> true
+ ```
+
+ @method typeInjection
+ @param {String} type
+ @param {String} property
+ @param {String} fullName
+ */
typeInjection: function(type, property, fullName) {
if (this.parent) { illegalChildOperation('typeInjection'); }
var injections = this.typeInjections.get(type);
+
if (!injections) {
injections = [];
this.typeInjections.set(type, injections);
}
- injections.push({ property: property, fullName: fullName });
+
+ injections.push({
+ property: property,
+ fullName: fullName
+ });
},
+ /*
+ Defines injection rules.
+
+ These rules are used to inject dependencies onto objects when they
+ are instantiated.
+
+ Two forms of injections are possible:
+
+ * Injecting one fullName on another fullName
+ * Injecting one fullName on a type
+
+ Example:
+
+ ```javascript
+ var container = new Container();
+
+ container.register('source:main', Source);
+ container.register('model:user', User);
+ container.register('model:post', PostController);
+
+ // injecting one fullName on another fullName
+ // eg. each user model gets a post model
+ container.injection('model:user', 'post', 'model:post');
+
+ // injecting one fullName on another type
+ container.injection('model', 'source', 'source:main');
+
+ var user = container.lookup('model:user');
+ var post = container.lookup('model:post');
+
+ user.source instanceof Source; //=> true
+ post.source instanceof Source; //=> true
+
+ user.post instanceof Post; //=> true
+
+ // and both models share the same source
+ user.source === post.source; //=> true
+ ```
+
+ @method injection
+ @param {String} factoryName
+ @param {String} property
+ @param {String} injectionName
+ */
injection: function(factoryName, property, injectionName) {
if (this.parent) { illegalChildOperation('injection'); }
@@ -163,6 +531,12 @@ define("container",
injections.push({ property: property, fullName: injectionName });
},
+ /**
+ A depth first traversal, destroying the container, its descendant containers and all
+ their managed objects.
+
+ @method destroy
+ */
destroy: function() {
this.isDestroyed = true;
@@ -180,6 +554,9 @@ define("container",
this.isDestroyed = true;
},
+ /**
+ @method reset
+ */
reset: function() {
for (var i=0, l=this.children.length; i<l; i++) {
resetCache(this.children[i]);
@@ -208,7 +585,12 @@ define("container",
for (var i=0, l=injections.length; i<l; i++) {
injection = injections[i];
lookup = container.lookup(injection.fullName);
- hash[injection.property] = lookup;
+
+ if (lookup) {
+ hash[injection.property] = lookup;
+ } else {
+ throw new Error('Attempting to inject an unknown injection: `' + injection.fullName + '`');
+ }
}
return hash; | true |
Other | emberjs | ember.js | 58fd8c71ea677cd4e1e97de5d50b105e9ec0d92d.json | Document the container | packages/container/tests/container_test.js | @@ -183,6 +183,19 @@ test("A failed lookup returns undefined", function() {
equal(container.lookup("doesnot:exist"), undefined);
});
+test("Injecting a failed lookup raises an error", function(){
+ var container = new Container();
+ var Foo = { create: function(){ }};
+
+ container.register('model:foo', Foo);
+
+ container.injection('model:foo', 'store', 'store:main');
+
+ throws(function(){
+ container.lookup('model:foo');
+ });
+});
+
test("Destroying the container destroys any cached singletons", function() {
var container = new Container();
var PostController = factory(); | true |
Other | emberjs | ember.js | 0ccf084c62367ad725b286e6be1526d07d88e8ee.json | Use Ember.isNone instead of Ember.none | packages/ember-views/lib/views/view.js | @@ -2455,7 +2455,7 @@ Ember.View.applyAttributeBindings = function(elem, name, value) {
}
} else if (name === 'value' || type === 'boolean') {
// We can't set properties to undefined or null
- if (Ember.none(value)) { value = ''; }
+ if (Ember.isNone(value)) { value = ''; }
if (value !== elem.prop(name)) {
// value and booleans should always be properties | false |
Other | emberjs | ember.js | f6e85ce7aeb4ba2bcff9d3faf0df5fffa60d1f37.json | Update router.js. Fixes #2897. | packages/ember-routing/lib/vendor/router.js | @@ -343,15 +343,16 @@ define("router",
*/
function getMatchPoint(router, handlers, objects, inputParams) {
- var objectsToMatch = objects.length,
- matchPoint = handlers.length,
+ var matchPoint = handlers.length,
providedModels = {}, i,
currentHandlerInfos = router.currentHandlerInfos || [],
params = {},
oldParams = router.currentParams || {},
activeTransition = router.activeTransition,
- handlerParams = {};
+ handlerParams = {},
+ obj;
+ objects = slice.call(objects);
merge(params, inputParams);
for (i = handlers.length - 1; i >= 0; i--) {
@@ -366,9 +367,9 @@ define("router",
if (handlerObj.isDynamic) {
// URL transition.
- if (objectsToMatch > 0) {
+ if (obj = getMatchPointObject(objects, handlerName, activeTransition, true)) {
hasChanged = true;
- providedModels[handlerName] = objects[--objectsToMatch];
+ providedModels[handlerName] = obj;
} else {
handlerParams[handlerName] = {};
for (var prop in handlerObj.params) {
@@ -378,38 +379,42 @@ define("router",
handlerParams[handlerName][prop] = params[prop] = newParam;
}
}
- } else if (handlerObj.hasOwnProperty('names') && handlerObj.names.length) {
+ } else if (handlerObj.hasOwnProperty('names')) {
// Named transition.
- if (objectsToMatch > 0) {
+ if (obj = getMatchPointObject(objects, handlerName, activeTransition, handlerObj.names.length)) {
hasChanged = true;
- providedModels[handlerName] = objects[--objectsToMatch];
- } else if (activeTransition && activeTransition.providedModels[handlerName]) {
-
- // Use model from previous transition attempt, preferably the resolved one.
- hasChanged = true;
- providedModels[handlerName] = activeTransition.providedModels[handlerName] ||
- activeTransition.resolvedModels[handlerName];
+ providedModels[handlerName] = obj;
} else {
var names = handlerObj.names;
handlerParams[handlerName] = {};
for (var j = 0, len = names.length; j < len; ++j) {
var name = names[j];
- handlerParams[handlerName][name] = params[name] = oldParams[name];
+ handlerParams[handlerName][name] = params[name] = oldParams[name] || params[name];
}
}
}
if (hasChanged) { matchPoint = i; }
}
- if (objectsToMatch > 0) {
+ if (objects.length > 0) {
throw "More context objects were passed than there are dynamic segments for the route: " + handlers[handlers.length - 1].handler;
}
return { matchPoint: matchPoint, providedModels: providedModels, params: params, handlerParams: handlerParams };
}
+ function getMatchPointObject(objects, handlerName, activeTransition, canUseProvidedObject) {
+ if (objects.length && canUseProvidedObject) {
+ return objects.pop();
+ } else if (activeTransition) {
+ // Use model from previous transition attempt, preferably the resolved one.
+ return (canUseProvidedObject && activeTransition.providedModels[handlerName]) ||
+ activeTransition.resolvedModels[handlerName];
+ }
+ }
+
/**
@private
@@ -882,15 +887,14 @@ define("router",
handler = handlerInfo.handler,
handlerName = handlerInfo.name,
seq = transition.sequence,
- errorAlreadyHandled = false,
- resolvedModel;
+ errorAlreadyHandled = false;
if (index < matchPoint) {
log(router, seq, handlerName + ": using context from already-active handler");
// We're before the match point, so don't run any hooks,
// just use the already resolved context from the handler.
- resolvedModel = handlerInfo.handler.context;
+ transition.resolvedModels[handlerInfo.name] = handlerInfo.handler.context;
return proceed();
}
@@ -930,8 +934,8 @@ define("router",
trigger(handlerInfos.slice(0, index + 1), true, ['error', reason, transition]);
if (handler.error) {
- handler.error(reason, transition); }
-
+ handler.error(reason, transition);
+ }
// Propagate the original error.
return RSVP.reject(reason);
@@ -958,14 +962,14 @@ define("router",
// want to use the value returned from `afterModel` in any way, but rather
// always resolve with the original `context` object.
- resolvedModel = context;
- return handler.afterModel && handler.afterModel(resolvedModel, transition);
+ transition.resolvedModels[handlerInfo.name] = context;
+ return handler.afterModel && handler.afterModel(context, transition);
}
function proceed() {
log(router, seq, handlerName + ": validation succeeded, proceeding");
- handlerInfo.context = transition.resolvedModels[handlerInfo.name] = resolvedModel;
+ handlerInfo.context = transition.resolvedModels[handlerInfo.name];
return validateEntry(transition, handlerInfos, index + 1, matchPoint, handlerParams);
}
}
@@ -997,7 +1001,7 @@ define("router",
return handler.context;
}
- if (handlerInfo.isDynamic && transition.providedModels.hasOwnProperty(handlerName)) {
+ if (transition.providedModels.hasOwnProperty(handlerName)) {
var providedModel = transition.providedModels[handlerName];
return typeof providedModel === 'function' ? providedModel() : providedModel;
} | false |
Other | emberjs | ember.js | 331d0c1d036274a00fc2d72dcb3c4783b7249949.json | Polyfill history.state for non-supporting browsers | packages/ember-routing/lib/location/history_location.js | @@ -5,6 +5,9 @@
var get = Ember.get, set = Ember.set;
var popstateFired = false;
+var supportsHistoryState = (function(){
+ return !!(window.history && history.hasOwnProperty('state'));
+})();
/**
Ember.HistoryLocation implements the location API using the browser's
@@ -67,9 +70,10 @@ Ember.HistoryLocation = Ember.Object.extend({
@param path {String}
*/
setURL: function(path) {
+ var state = this.getState();
path = this.formatURL(path);
- if (this.getState() && this.getState().path !== path) {
+ if (state && state.path !== path) {
this.pushState(path);
}
},
@@ -84,9 +88,10 @@ Ember.HistoryLocation = Ember.Object.extend({
@param path {String}
*/
replaceURL: function(path) {
+ var state = this.getState();
path = this.formatURL(path);
- if (this.getState() && this.getState().path !== path) {
+ if (state && state.path !== path) {
this.replaceState(path);
}
},
@@ -95,11 +100,13 @@ Ember.HistoryLocation = Ember.Object.extend({
@private
Get the current `history.state`
+ Polyfill checks for native browser support and falls back to retrieving
+ from a private _historyState variable
@method getState
*/
getState: function() {
- return get(this, 'history').state;
+ return supportsHistoryState ? get(this, 'history').state : this._historyState;
},
/**
@@ -111,7 +118,15 @@ Ember.HistoryLocation = Ember.Object.extend({
@param path {String}
*/
pushState: function(path) {
- get(this, 'history').pushState({ path: path }, null, path);
+ var state = { path: path };
+
+ get(this, 'history').pushState(state, null, path);
+
+ // store state if browser doesn't support `history.state`
+ if(!supportsHistoryState) {
+ this._historyState = state;
+ }
+
// used for webkit workaround
this._previousURL = this.getURL();
},
@@ -125,7 +140,15 @@ Ember.HistoryLocation = Ember.Object.extend({
@param path {String}
*/
replaceState: function(path) {
- get(this, 'history').replaceState({ path: path }, null, path);
+ var state = { path: path };
+
+ get(this, 'history').replaceState(state, null, path);
+
+ // store state if browser doesn't support `history.state`
+ if(!supportsHistoryState) {
+ this._historyState = state;
+ }
+
// used for webkit workaround
this._previousURL = this.getURL();
}, | false |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | Gemfile | @@ -2,6 +2,7 @@ source "https://rubygems.org"
gem "rake-pipeline", :git => "https://github.com/livingsocial/rake-pipeline.git"
gem "ember-dev", :git => "https://github.com/emberjs/ember-dev.git", :branch => "master"
+gem "handlebars-source", :git => "https://github.com/wycats/handlebars.js.git", :tag => "v1.0.12"
# Require the specific version of handlebars-source that
# we'll be precompiling and performing tests with. | true |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | Gemfile.lock | @@ -23,11 +23,18 @@ GIT
rake (~> 10.0.0)
thor
+GIT
+ remote: https://github.com/wycats/handlebars.js.git
+ revision: 1585f917498f47263f3cd6dc4343ac377e93ad22
+ tag: v1.0.12
+ specs:
+ handlebars-source (1.0.12)
+
PATH
remote: .
specs:
ember-source (1.0.0.rc6)
- handlebars-source (= 1.0.0.rc4)
+ handlebars-source (= 1.0.12)
GEM
remote: https://rubygems.org/
@@ -45,7 +52,6 @@ GEM
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
- handlebars-source (1.0.0.rc4)
json (1.8.0)
kicker (2.6.1)
listen
@@ -79,4 +85,5 @@ PLATFORMS
DEPENDENCIES
ember-dev!
ember-source!
+ handlebars-source!
rake-pipeline! | true |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | ember-source.gemspec | @@ -12,9 +12,7 @@ Gem::Specification.new do |gem|
gem.version = Ember.rubygems_version_string
- # Note: can't use the squiggly ~> operator the way we'd expect
- # so long as we're referencing pre-release versions.
- gem.add_dependency "handlebars-source", ["1.0.0.rc4"]
+ gem.add_dependency "handlebars-source", ["1.0.12"]
gem.files = %w(VERSION) + Dir['dist/*.js', 'lib/ember/*.rb']
end | true |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | packages/ember-handlebars-compiler/lib/main.js | @@ -15,8 +15,8 @@ if(!Handlebars && typeof require === 'function') {
Handlebars = require('handlebars');
}
-Ember.assert("Ember Handlebars requires Handlebars version 1.0.0-rc.4. Include a SCRIPT tag in the HTML HEAD linking to the Handlebars file before you link to Ember.", Handlebars)
-Ember.assert("Ember Handlebars requires Handlebars version 1.0.0-rc.4, COMPILER_REVISION expected: 3, got: " + Handlebars.COMPILER_REVISION + " – Please note: Builds of master may have other COMPILER_REVISION values.", Handlebars.COMPILER_REVISION === 3);
+Ember.assert("Ember Handlebars requires Handlebars version 1.0.0. Include a SCRIPT tag in the HTML HEAD linking to the Handlebars file before you link to Ember.", Handlebars)
+Ember.assert("Ember Handlebars requires Handlebars version 1.0.0, COMPILER_REVISION expected: 4, got: " + Handlebars.COMPILER_REVISION + " – Please note: Builds of master may have other COMPILER_REVISION values.", Handlebars.COMPILER_REVISION === 4);
/**
Prepares the Handlebars templating library for use inside Ember's view
@@ -203,7 +203,7 @@ Ember.Handlebars.Compiler.prototype.mustache = function(mustache) {
} else if (mustache.params.length || mustache.hash) {
// no changes required
} else {
- var id = new Handlebars.AST.IdNode(['_triageMustache']);
+ var id = new Handlebars.AST.IdNode([{ part: '_triageMustache' }]);
// Update the mustache node to include a hash value indicating whether the original node
// was escaped. This will allow us to properly escape values when the underlying value | true |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | packages/ember-handlebars/tests/helpers/partial_test.js | @@ -49,7 +49,7 @@ test("should render other slash-separated templates registered with the containe
});
test("should use the current view's context", function(){
- container.register('template:_person_name', Ember.Handlebars.compile("{{{firstName}} {{lastName}}"));
+ container.register('template:_person_name', Ember.Handlebars.compile("{{firstName}} {{lastName}}"));
view = Ember.View.create({
container: container, | true |
Other | emberjs | ember.js | 4023186ea157a8687ac611181e2ca49e5fc891d5.json | Update Handlebars version. | packages/ember-handlebars/tests/helpers/template_test.js | @@ -34,7 +34,7 @@ test("should render other templates via the container", function() {
});
test("should use the current view's context", function(){
- container.register('template:person_name', Ember.Handlebars.compile("{{{firstName}} {{lastName}}"));
+ container.register('template:person_name', Ember.Handlebars.compile("{{firstName}} {{lastName}}"));
view = Ember.View.create({
container: container, | true |
Other | emberjs | ember.js | 21cd24adc3dd3a12c4a90c830ebabc595287c3d0.json | fix some consistencies mistakes
I don't know if the remainings `control` terms are legits or not, so I didn't touch them. Please let me now if all `control` should be renamed to `component`. cc/ @wycats | packages/ember-views/lib/views/component.js | @@ -15,7 +15,7 @@ require("ember-views/views/view");
The easiest way to create an `Ember.Component` is via
a template. If you name a template
- `controls/my-foo`, you will be able to use
+ `components/my-foo`, you will be able to use
`{{my-foo}}` in other templates, which will make
an instance of the isolated control.
@@ -34,9 +34,9 @@ require("ember-views/views/view");
include the **contents** of the custom tag:
```html
- {{#my-profile person=currentUser}}
+ {{#app-profile person=currentUser}}
<p>Admin mode</p>
- {{/my-profile}}
+ {{/app-profile}}
```
```html | false |
Other | emberjs | ember.js | 42f0c68a6f88c5bfd4c6420bcb8706a009f5f277.json | update lock file | Gemfile.lock | @@ -26,7 +26,7 @@ GIT
PATH
remote: .
specs:
- ember-source (1.0.0.rc5)
+ ember-source (1.0.0.rc6)
handlebars-source (= 1.0.0.rc4)
GEM | false |
Other | emberjs | ember.js | 344390e20e1133c7726f20f71fb0b7854b82f153.json | Add code comment | packages/ember-runtime/lib/system/string.js | @@ -239,8 +239,8 @@ Ember.String = {
```
@method capitalize
- @param {String} str
- @return {String}
+ @param {String} str The string to capitalize.
+ @return {String} The capitalized string.
*/
capitalize: function(str) {
return str.charAt(0).toUpperCase() + str.substr(1); | false |
Other | emberjs | ember.js | a24529e4742d45ffee624f2b6ddf2937c512b228.json | Remove unnecessary existing check for `Ember`
Now `Ember` is exist when `Ember.deprecate` is called. | packages/ember-debug/lib/main.js | @@ -95,12 +95,12 @@ Ember.debug = function(message) {
will be displayed.
*/
Ember.deprecate = function(message, test) {
- if (Ember && Ember.TESTING_DEPRECATION) { return; }
+ if (Ember.TESTING_DEPRECATION) { return; }
if (arguments.length === 1) { test = false; }
if (test) { return; }
- if (Ember && Ember.ENV.RAISE_ON_DEPRECATION) { throw new Error(message); }
+ if (Ember.ENV.RAISE_ON_DEPRECATION) { throw new Error(message); }
var error;
| false |
Other | emberjs | ember.js | 854a460682b1c15ba28f7e3e7519952c70249754.json | Add test for parentViewDidChange event. | packages/ember-views/tests/views/container_view_test.js | @@ -111,6 +111,29 @@ test("should set the parentView property on views that are added to the child vi
});
});
+test("should trigger parentViewDidChange when parentView is changed", function() {
+ container = Ember.ContainerView.create();
+
+ var secondContainer = Ember.ContainerView.create();
+ var parentViewChanged = 0;
+
+ var View = Ember.View.extend({
+ parentViewDidChange: function() { parentViewChanged++; }
+ });
+
+ view = View.create();
+
+ container.pushObject(view);
+ container.removeChild(view);
+ secondContainer.pushObject(view);
+
+ equal(parentViewChanged, 3);
+
+ Ember.run(function() {
+ secondContainer.destroy();
+ });
+});
+
test("views that are removed from a ContainerView should have their child views cleared", function() {
container = Ember.ContainerView.create();
view = Ember.View.createWithMixins({ | false |
Other | emberjs | ember.js | 2ec3b2120ee1c6cfeee1a400d5cbae1c7d3bf781.json | Fix wrong example
An empty '<option>' is not render until `prompt` is set. | packages/ember-handlebars/lib/controls/select.js | @@ -158,7 +158,6 @@ Ember.SelectOption = Ember.View.extend({
```html
<select class="ember-select">
- <option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2">Tom</option>
</select>
@@ -191,7 +190,6 @@ Ember.SelectOption = Ember.View.extend({
```html
<select class="ember-select">
- <option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2" selected="selected">Tom</option>
</select>
@@ -229,7 +227,6 @@ Ember.SelectOption = Ember.View.extend({
```html
<select class="ember-select">
- <option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2" selected="selected">Tom</option>
</select> | false |
Other | emberjs | ember.js | a7ab858f9ef8496c8940cf8acc98d6f4ddff2dc1.json | add test for user provided template on a view | packages/ember/tests/routing/basic_test.js | @@ -244,6 +244,26 @@ test('render does not replace templateName if user provided', function() {
equal(Ember.$('p', '#qunit-fixture').text(), "THIS IS THE REAL HOME", "The homepage template was rendered");
});
+test('render does not replace template if user provided', function () {
+ Router.map(function () {
+ this.route("home", { path: "/" });
+ });
+
+ App.HomeView = Ember.View.extend({
+ template: Ember.Handlebars.compile("<p>THIS IS THE REAL HOME</p>")
+ });
+ App.HomeController = Ember.Controller.extend();
+ App.HomeRoute = Ember.Route.extend();
+
+ bootApplication();
+
+ Ember.run(function () {
+ router.handleURL("/");
+ });
+
+ equal(Ember.$('p', '#qunit-fixture').text(), "THIS IS THE REAL HOME", "The homepage template was rendered");
+});
+
test("The Homepage with a `setupController` hook", function() {
Router.map(function() {
this.route("home", { path: "/" }); | false |
Other | emberjs | ember.js | 574c10b8a99a38c0b13fd0dc42c138a07ff629ea.json | Add tests for #1866 - loc helper | packages/ember-handlebars/lib/helpers/loc.js | @@ -15,6 +15,9 @@ require('ember-handlebars/ext');
</script>
```
+ Take note that `welcome` is a string and not an object
+ reference.
+
@method loc
@for Ember.Handlebars.helpers
@param {String} str The string to format | true |
Other | emberjs | ember.js | 574c10b8a99a38c0b13fd0dc42c138a07ff629ea.json | Add tests for #1866 - loc helper | packages/ember-handlebars/tests/helpers/loc_test.js | @@ -0,0 +1,51 @@
+var buildView = function(template, context) {
+ return Ember.View.create({
+ template: Ember.Handlebars.compile(template),
+ context: (context || {})
+ });
+};
+
+var appendView = function(view) {
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+};
+
+var destroyView = function(view) {
+ Ember.run(function(){
+ view.destroy();
+ });
+};
+
+var oldString;
+
+module('Handlebars {{loc valueToLocalize}} helper', {
+ setup: function() {
+ oldString = Ember.STRINGS;
+ Ember.STRINGS = {
+ '_Howdy Friend': 'Hallo Freund'
+ };
+ },
+
+ teardown: function() {
+ Ember.STRINGS = oldString;
+ }
+});
+
+test("let the original value through by default", function() {
+ var view = buildView('{{loc "Hiya buddy!"}}');
+ appendView(view);
+
+ equal(view.$().text(), "Hiya buddy!");
+
+ destroyView(view);
+});
+
+test("localize a simple string", function() {
+ var view = buildView('{{loc "_Howdy Friend"}}');
+ appendView(view);
+
+ equal(view.$().text(), "Hallo Freund");
+
+ destroyView(view);
+}); | true |
Other | emberjs | ember.js | 0e919f5e99c3615759a11e9bf8832434e8711ee8.json | add loc helper | packages/ember-handlebars/lib/helpers.js | @@ -8,3 +8,4 @@ require("ember-handlebars/helpers/each");
require("ember-handlebars/helpers/template");
require("ember-handlebars/helpers/partial");
require("ember-handlebars/helpers/yield");
+require("ember-handlebars/helpers/loc"); | true |
Other | emberjs | ember.js | 0e919f5e99c3615759a11e9bf8832434e8711ee8.json | add loc helper | packages/ember-handlebars/lib/helpers/loc.js | @@ -0,0 +1,25 @@
+require('ember-handlebars/ext');
+
+/**
+@module ember
+@submodule ember-handlebars
+*/
+
+/**
+ `loc` looks up the string in the localized strings hash.
+ This is a convenient way to localize text. For example:
+
+ ```html
+ <script type="text/x-handlebars" data-template-name="home">
+ {{loc welcome}}
+ </script>
+ ```
+
+ @method loc
+ @for Ember.Handlebars.helpers
+ @param {String} str The string to format
+*/
+
+Ember.Handlebars.registerHelper('loc', function(str) {
+ return Ember.String.loc(str);
+}); | true |
Other | emberjs | ember.js | b71a406d25679acbc154bd75c8feab9fc4047569.json | Fix code comment | packages/ember-metal/lib/set_properties.js | @@ -10,9 +10,9 @@ var changeProperties = Ember.changeProperties,
observers will be buffered.
@method setProperties
- @param target
- @param {Hash} properties
- @return target
+ @param self
+ @param {Object} hash
+ @return self
*/
Ember.setProperties = function(self, hash) {
changeProperties(function(){ | false |
Other | emberjs | ember.js | 6f6e7103d174be95cc62e87f28bcc753d6045062.json | Expand helper function | packages/ember-metal/lib/property_get.js | @@ -89,10 +89,6 @@ if (Ember.config.overrideAccessors) {
get = Ember.get;
}
-function firstKey(path) {
- return path.match(FIRST_KEY)[0];
-}
-
/**
@private
@@ -116,7 +112,7 @@ var normalizeTuple = Ember.normalizeTuple = function(target, path) {
if (hasThis) path = path.slice(5);
if (target === Ember.lookup) {
- key = firstKey(path);
+ key = path.match(FIRST_KEY)[0];
target = get(target, key);
path = path.slice(key.length+1);
} | false |
Other | emberjs | ember.js | 5079d4efc5eb694354c3afb89f5af30aafb2fb54.json | Improve docs for event names | packages/ember-views/lib/views/view.js | @@ -759,8 +759,10 @@ class:
### Event Names
- Possible events names for any of the responding approaches described above
- are:
+ All of the event handling approaches described above respond to the same set
+ of events. The names of the built-in events are listed below. (The hash of
+ built-in events exists in `Ember.EventDispatcher`.) Additional, custom events
+ can be registered by using `Ember.Application.customEvents`.
Touch events:
| false |
Other | emberjs | ember.js | 7138bbbf22aaafb0791023b5f45b2bd5c719a08e.json | Remove expectAssertion in favor of ember-dev | Gemfile.lock | @@ -1,6 +1,6 @@
GIT
remote: https://github.com/emberjs/ember-dev.git
- revision: 104afee9ca7bf406af545126f377f696c0c10581
+ revision: d064bd6c33e87979aa5b852f8eb853c39b190e87
branch: master
specs:
ember-dev (0.1) | true |
Other | emberjs | ember.js | 7138bbbf22aaafb0791023b5f45b2bd5c719a08e.json | Remove expectAssertion in favor of ember-dev | tests/ember_configuration.js | @@ -41,57 +41,5 @@
runtime: 'ember-runtime.js'
};
- function expectAssertion(fn, expectedMessage) {
- var originalAssert = Ember.assert,
- actualMessage, actualTest,
- arity, sawAssertion;
- var AssertionFailedError = new Error('AssertionFailed');
-
- try {
- Ember.assert = function(message, test) {
- arity = arguments.length;
- actualMessage = message;
- actualTest = test;
-
- if (!test) {
- throw AssertionFailedError;
- }
- };
-
- try {
- fn();
- } catch(error) {
- if (error === AssertionFailedError) {
- sawAssertion = true;
- } else {
- throw error;
- }
- }
-
- if (!sawAssertion) {
- ok(false, "Expected Ember.assert: '" + expectedMessage + "', but no assertions where run");
- } else if (arity === 2) {
-
- if (expectedMessage) {
- if (expectedMessage instanceof RegExp) {
- ok(expectedMessage.test(actualMessage), "Expected Ember.assert: '" + expectedMessage + "', but got '" + actualMessage + "'");
- }else{
- equal(actualMessage, expectedMessage, "Expected Ember.assert: '" + expectedMessage + "', but got '" + actualMessage + "'");
- }
- } else {
- ok(!actualTest);
- }
- } else if (arity === 1) {
- ok(!actualTest);
- } else {
- ok(false, 'Ember.assert was called without the assertion');
- }
-
- } finally {
- Ember.assert = originalAssert;
- }
- }
-
- window.expectAssertion = expectAssertion;
})(); | true |
Other | emberjs | ember.js | 6867a0b14a1bbee72e81b4245628f0a5f78803df.json | Fix failing tests for non-blocking assertions | packages/ember-handlebars/lib/main.js | @@ -1,5 +1,5 @@
-require("ember-handlebars-compiler");
require("ember-runtime");
+require("ember-handlebars-compiler");
require("ember-views");
require("ember-handlebars/ext");
require("ember-handlebars/string"); | true |
Other | emberjs | ember.js | 6867a0b14a1bbee72e81b4245628f0a5f78803df.json | Fix failing tests for non-blocking assertions | packages/ember-old-router/tests/routable_test.js | @@ -670,7 +670,7 @@ test("if a leaf state has a redirectsTo, it automatically transitions into that
});
test("you cannot define connectOutlets AND redirectsTo", function() {
- raises(function() {
+ expectAssertion(function() {
Ember.Router.create({
location: 'none',
root: Ember.Route.create({
@@ -685,7 +685,7 @@ test("you cannot define connectOutlets AND redirectsTo", function() {
});
test("you cannot have a redirectsTo in a non-leaf state", function () {
- raises(function() {
+ expectAssertion(function() {
Ember.Router.create({
location: 'none',
root: Ember.Route.create({
@@ -736,7 +736,7 @@ test("urlFor raises an error when route property is not defined", function() {
})
});
- raises(function (){
+ expectAssertion(function (){
router.urlFor('root.dashboard');
});
}); | true |
Other | emberjs | ember.js | f872a78760d5111b0e468a06389d549cb8832ab2.json | Utilize the browser console.assert when possible
Currently our asserts are catchable by try/catches.
This can occur accidentally, hiding real issues in
both user code, framework code, and explicitly in
promises.
Chrome's currently implementation of console.assert
is not catchable, and does not interfere with the
programs execution. This is likely how we should model
our assert system. | .jshintrc | @@ -25,7 +25,8 @@
"strictEqual",
"module",
"expect",
- "minispade"
+ "minispade",
+ "expectAssertion"
],
"node" : false, | true |
Other | emberjs | ember.js | f872a78760d5111b0e468a06389d549cb8832ab2.json | Utilize the browser console.assert when possible
Currently our asserts are catchable by try/catches.
This can occur accidentally, hiding real issues in
both user code, framework code, and explicitly in
promises.
Chrome's currently implementation of console.assert
is not catchable, and does not interfere with the
programs execution. This is likely how we should model
our assert system. | packages/ember-debug/lib/main.js | @@ -44,7 +44,7 @@ if (!('MANDATORY_SETTER' in Ember.ENV)) {
falsy, an exception will be thrown.
*/
Ember.assert = function(desc, test) {
- if (!test) throw new Error("assertion failed: "+desc);
+ Ember.Logger.assert(test, desc);
};
| true |
Other | emberjs | ember.js | f872a78760d5111b0e468a06389d549cb8832ab2.json | Utilize the browser console.assert when possible
Currently our asserts are catchable by try/catches.
This can occur accidentally, hiding real issues in
both user code, framework code, and explicitly in
promises.
Chrome's currently implementation of console.assert
is not catchable, and does not interfere with the
programs execution. This is likely how we should model
our assert system. | packages/ember-metal/lib/core.js | @@ -167,6 +167,19 @@ function consoleMethod(name) {
}
}
+function assertPolyfill(test, message) {
+ if (!test) {
+ try {
+ // attempt to preserve the stack
+ throw new Error("assertion failed: " + message);
+ } catch(error) {
+ setTimeout(function(){
+ throw error;
+ }, 0);
+ }
+ }
+}
+
/**
Inside Ember-Metal, simply uses the methods from `imports.console`.
Override this to provide more robust logging functionality.
@@ -179,7 +192,8 @@ Ember.Logger = {
warn: consoleMethod('warn') || Ember.K,
error: consoleMethod('error') || Ember.K,
info: consoleMethod('info') || Ember.K,
- debug: consoleMethod('debug') || consoleMethod('info') || Ember.K
+ debug: consoleMethod('debug') || consoleMethod('info') || Ember.K,
+ assert: consoleMethod('assert') || assertPolyfill
};
| true |
Other | emberjs | ember.js | f872a78760d5111b0e468a06389d549cb8832ab2.json | Utilize the browser console.assert when possible
Currently our asserts are catchable by try/catches.
This can occur accidentally, hiding real issues in
both user code, framework code, and explicitly in
promises.
Chrome's currently implementation of console.assert
is not catchable, and does not interfere with the
programs execution. This is likely how we should model
our assert system. | tests/ember_configuration.js | @@ -40,4 +40,59 @@
prod: 'ember.prod.js',
runtime: 'ember-runtime.js'
};
+
+ function expectAssertion(fn, expectedMessage) {
+ var originalAssert = Ember.assert,
+ actualMessage, actualTest,
+ arity, sawAssertion;
+
+ var AssertionFailedError = new Error('AssertionFailed');
+
+ try {
+
+ Ember.assert = function(message, test) {
+ arity = arguments.length;
+ actualMessage = message;
+ actualTest = test;
+
+ if (!test) {
+ throw AssertionFailedError;
+ }
+ };
+
+ try {
+ fn();
+ } catch(error) {
+ if (error === AssertionFailedError) {
+ sawAssertion = true;
+ } else {
+ throw error;
+ }
+ }
+
+ if (!sawAssertion) {
+ ok(false, "Expected Ember.assert: '" + expectedMessage + "', but no assertions where run");
+ } else if (arity === 2) {
+
+ if (expectedMessage) {
+ if (expectedMessage instanceof RegExp) {
+ ok(expectedMessage.test(actualMessage), "Expected Ember.assert: '" + expectedMessage + "', but got '" + actualMessage + "'");
+ }else{
+ equal(actualMessage, expectedMessage, "Expected Ember.assert: '" + expectedMessage + "', but got '" + actualMessage + "'");
+ }
+ } else {
+ ok(!actualTest);
+ }
+ } else if (arity === 1) {
+ ok(!actualTest);
+ } else {
+ ok(false, 'Ember.assert was called without the assertion');
+ }
+
+ } finally {
+ Ember.assert = originalAssert;
+ }
+ }
+
+ window.expectAssertion = expectAssertion;
})(); | true |
Other | emberjs | ember.js | a8384b2aeee841bcfa6c400d538dee03c27a12ba.json | Fix typo in array mixin docs | packages/ember-runtime/lib/mixins/array.js | @@ -242,15 +242,15 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
Adds an array observer to the receiving array. The array observer object
normally must implement two methods:
- * `arrayWillChange(start, removeCount, addCount)` - This method will be
+ * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be
called just before the array is modified.
- * `arrayDidChange(start, removeCount, addCount)` - This method will be
+ * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be
called just after the array is modified.
- Both callbacks will be passed the starting index of the change as well a
- a count of the items to be removed and added. You can use these callbacks
- to optionally inspect the array during the change, clear caches, or do
- any other bookkeeping necessary.
+ Both callbacks will be passed the observed object, starting index of the
+ change as well a a count of the items to be removed and added. You can use
+ these callbacks to optionally inspect the array during the change, clear
+ caches, or do any other bookkeeping necessary.
In addition to passing a target, you can also include an options hash
which you can use to override the method names that will be invoked on the | false |
Other | emberjs | ember.js | 07ed2e2bedba5a9b584800d4d84517fd03a28c78.json | Clarify subclasses of Ember.CoreView #2556 | packages/ember-handlebars/lib/views/metamorph_view.js | @@ -124,7 +124,7 @@ Ember._MetamorphView = Ember.View.extend(Ember._Metamorph);
/**
@class _SimpleMetamorphView
@namespace Ember
- @extends Ember.View
+ @extends Ember.CoreView
@uses Ember._Metamorph
@private
*/ | true |
Other | emberjs | ember.js | 07ed2e2bedba5a9b584800d4d84517fd03a28c78.json | Clarify subclasses of Ember.CoreView #2556 | packages/ember-views/lib/views/view.js | @@ -47,6 +47,15 @@ Ember.warn("The VIEW_PRESERVES_CONTEXT flag has been removed and the functionali
*/
Ember.TEMPLATES = {};
+/**
+ `Ember.CoreView` is
+
+ @class CoreView
+ @namespace Ember
+ @extends Ember.Object
+ @uses Ember.Evented
+*/
+
Ember.CoreView = Ember.Object.extend(Ember.Evented, {
isView: true,
@@ -804,8 +813,7 @@ class:
@class View
@namespace Ember
- @extends Ember.Object
- @uses Ember.Evented
+ @extends Ember.CoreView
*/
Ember.View = Ember.CoreView.extend(
/** @scope Ember.View.prototype */ { | true |
Other | emberjs | ember.js | 7cc5db0544053b0d40f2f78f7f765ef98ff4f1fe.json | Remove unnecessary comment | packages/ember-views/lib/main.js | @@ -1,5 +1,3 @@
-/*globals jQuery*/
-
require("ember-runtime");
require("container");
| false |
Other | emberjs | ember.js | ef6b83956d5869b1a6b076b60f13940138ac8358.json | Remove unused variables | packages/ember-testing/lib/helpers.js | @@ -55,7 +55,7 @@ function find(app, selector, context) {
}
function wait(app, value) {
- var promise, obj = {}, helperName;
+ var promise;
promise = Ember.Test.promise(function(resolve) {
if (++countAsync === 1) { | true |
Other | emberjs | ember.js | ef6b83956d5869b1a6b076b60f13940138ac8358.json | Remove unused variables | packages/ember-testing/lib/test.js | @@ -103,7 +103,7 @@ Ember.Test = {
chained: false
};
thenable.then = function(onSuccess, onFailure) {
- var self = this, thenPromise, nextPromise;
+ var thenPromise, nextPromise;
thenable.chained = true;
thenPromise = promise.then(onSuccess, onFailure);
// this is to ensure all downstream fulfillment | true |
Other | emberjs | ember.js | b1e4fe508b1544a6a1525a4045c671e4fc5477b0.json | Remove unnecessary require | ember-source.gemspec | @@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
-require 'json'
require "./lib/ember/version"
Gem::Specification.new do |gem| | false |
Other | emberjs | ember.js | 24aff50818c1f28c1c0b1690cd379091f6c99d15.json | Remove ember-testing from production build | Assetfile | @@ -4,7 +4,7 @@ distros = {
"runtime" => %w(ember-metal rsvp container ember-runtime),
"template-compiler" => %w(ember-handlebars-compiler),
"data-deps" => %w(ember-metal rsvp container ember-runtime ember-states),
- "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph handlebars ember-handlebars-compiler ember-handlebars ember-routing ember-application ember-states ember-testing),
+ "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph handlebars ember-handlebars-compiler ember-handlebars ember-routing ember-application ember-states),
"old-router" => %w(ember-metal rsvp container ember-runtime ember-views ember-states ember-viewstates metamorph handlebars ember-handlebars-compiler ember-handlebars ember-old-router)
}
@@ -42,9 +42,20 @@ distros.each do |name, modules|
name = name == "full" ? "ember" : "ember-#{name}"
input "dist/modules" do
+
+ # Add ember-testing to ember distro
+ if name == "ember"
+ match "{ember-testing.js}" do
+ concat ["ember-testing.js"], "#{name}.js"
+ end
+ end
+
module_paths = modules.map{|m| "#{m}.js" }
match "{#{module_paths.join(',')}}" do
concat(module_paths){ ["#{name}.js", "#{name}.prod.js"] }
+ end
+
+ match "{#{name}.js,#{name}.prod.js}" do
filter HandlebarsPrecompiler
filter AddMicroLoader unless name == "ember-template-compiler"
end | false |
Other | emberjs | ember.js | 8267e07a7b054421122f34a73c68c43c8e33204a.json | Fix failing tests in IE7 by normalizing URL
IE7 includes host hame in href attribute. | packages/ember/tests/helpers/link_to_test.js | @@ -247,7 +247,7 @@ test("The {{linkTo}} helper supports leaving off .index for nested routes", func
router.handleURL("/about/item");
});
- equal(Ember.$('#item a', '#qunit-fixture').attr('href'), '/about');
+ equal(normalizeUrl(Ember.$('#item a', '#qunit-fixture').attr('href')), '/about');
});
test("The {{linkTo}} helper supports custom, nested, currentWhen", function() {
@@ -429,7 +429,7 @@ test("The {{linkTo}} helper accepts string arguments", function() {
Ember.run(function() { router.handleURL("/filters/popular"); });
- equal(Ember.$('#link', '#qunit-fixture').attr('href'), "/filters/unpopular");
+ equal(normalizeUrl(Ember.$('#link', '#qunit-fixture').attr('href')), "/filters/unpopular");
});
test("The {{linkTo}} helper unwraps controllers", function() { | false |
Other | emberjs | ember.js | 9e75b058a240af6d9681ddeda1260b027c5c1172.json | Update backburner to fix IE8 failing test | packages/ember-metal/lib/vendor/backburner.js | @@ -165,7 +165,7 @@ define("backburner",
clearTimeout(laterTimer);
laterTimer = null;
}
- laterTimer = setTimeout(function() {
+ laterTimer = window.setTimeout(function() {
executeTimers(self);
laterTimer = null;
laterTimerExpiresAt = null;
@@ -186,7 +186,7 @@ define("backburner",
if (debouncee[0] === target && debouncee[1] === method) { return; } // do nothing
}
- var timer = setTimeout(function() {
+ var timer = window.setTimeout(function() {
self.run.apply(self, args);
// remove debouncee
@@ -247,7 +247,7 @@ define("backburner",
function createAutorun(backburner) {
backburner.begin();
- autorun = setTimeout(function() {
+ autorun = window.setTimeout(function() {
backburner.end();
autorun = null;
});
@@ -272,7 +272,7 @@ define("backburner",
});
if (timers.length) {
- laterTimer = setTimeout(function() {
+ laterTimer = window.setTimeout(function() {
executeTimers(self);
laterTimer = null;
laterTimerExpiresAt = null;
@@ -473,4 +473,4 @@ define("backburner/queue",
};
__exports__.Queue = Queue;
- });
\ No newline at end of file
+ }); | false |
Other | emberjs | ember.js | 6c53d40d7bba3cd23edb7e86ef145386df64d86a.json | maintain ruby'esq version string for gems | ember-source.gemspec | @@ -10,7 +10,8 @@ Gem::Specification.new do |gem|
gem.summary = %q{Ember.js source code wrapper.}
gem.description = %q{Ember.js source code wrapper for use with Ruby libs.}
gem.homepage = "https://github.com/emberjs/ember.js"
- gem.version = Ember::VERSION.gsub('-','.')
+
+ gem.version = Ember.rubygems_version_string
# Note: can't use the squiggly ~> operator the way we'd expect
# so long as we're referencing pre-release versions. | true |
Other | emberjs | ember.js | 6c53d40d7bba3cd23edb7e86ef145386df64d86a.json | maintain ruby'esq version string for gems | lib/ember/version.rb | @@ -1,3 +1,13 @@
module Ember
+ extend self
+
VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).strip
+
+ # we might want to unify this with the ember version string,
+ # but consistency?
+ def rubygems_version_string
+ major, rc = VERSION.sub('-','.').scan(/(\d+\.\d+\.\d+\.rc)\.(\d+)/).first
+
+ "#{major}#{rc}"
+ end
end | true |
Other | emberjs | ember.js | c71352f70a4f19fb70ebe1dfcd2bc20878731f62.json | remove starter_kit upload task
(we just use the github tarbals) | Rakefile | @@ -86,19 +86,14 @@ namespace :release do
end
end
- desc "Upload release"
- task :upload do
- puts 'upload the starter kit manually'
- end
-
desc "Build the Ember.js starter kit"
task :build => "dist/starter-kit.#{Ember::VERSION}.zip"
desc "Prepare starter-kit for release"
task :prepare => []
desc "Release starter-kit"
- task :deploy => [:build, :update, :upload]
+ task :deploy => [:build, :update]
end
namespace :website do | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.