ember-source 1.9.0.beta.4 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ember-source might be problematic. Click here for more details.

@@ -5,7 +5,7 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 1.9.0-beta.4
8
+ * @version 1.9.0
9
9
  */
10
10
 
11
11
  (function() {
@@ -14,6 +14,7 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
14
14
  (function() {
15
15
  Ember = this.Ember = this.Ember || {};
16
16
  if (typeof Ember === 'undefined') { Ember = {}; };
17
+ function UNDEFINED() { }
17
18
 
18
19
  if (typeof Ember.__loader === 'undefined') {
19
20
  var registry = {}, seen = {};
@@ -23,7 +24,11 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
23
24
  };
24
25
 
25
26
  requirejs = eriuqer = requireModule = function(name) {
26
- if (seen.hasOwnProperty(name)) { return seen[name]; }
27
+ var s = seen[name];
28
+
29
+ if (s !== undefined) { return seen[name]; }
30
+ if (s === UNDEFINED) { return undefined; }
31
+
27
32
  seen[name] = {};
28
33
 
29
34
  if (!registry[name]) {
@@ -35,34 +40,37 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
35
40
  var callback = mod.callback;
36
41
  var reified = [];
37
42
  var exports;
43
+ var length = deps.length;
38
44
 
39
- for (var i=0, l=deps.length; i<l; i++) {
45
+ for (var i=0; i<length; i++) {
40
46
  if (deps[i] === 'exports') {
41
47
  reified.push(exports = {});
42
48
  } else {
43
- reified.push(requireModule(resolve(deps[i])));
49
+ reified.push(requireModule(resolve(deps[i], name)));
44
50
  }
45
51
  }
46
52
 
47
- var value = callback.apply(this, reified);
48
- return seen[name] = exports || value;
53
+ var value = length === 0 ? callback.call(this) : callback.apply(this, reified);
49
54
 
50
- function resolve(child) {
51
- if (child.charAt(0) !== '.') { return child; }
52
- var parts = child.split("/");
53
- var parentBase = name.split("/").slice(0, -1);
55
+ return seen[name] = exports || (value === undefined ? UNDEFINED : value);
56
+ };
54
57
 
55
- for (var i=0, l=parts.length; i<l; i++) {
56
- var part = parts[i];
58
+ function resolve(child, name) {
59
+ if (child.charAt(0) !== '.') { return child; }
60
+ var parts = child.split("/");
61
+ var parentBase = name.split("/").slice(0, -1);
57
62
 
58
- if (part === '..') { parentBase.pop(); }
59
- else if (part === '.') { continue; }
60
- else { parentBase.push(part); }
61
- }
63
+ for (var i=0, l=parts.length; i<l; i++) {
64
+ var part = parts[i];
62
65
 
63
- return parentBase.join("/");
66
+ if (part === '..') { parentBase.pop(); }
67
+ else if (part === '.') { continue; }
68
+ else { parentBase.push(part); }
64
69
  }
65
- };
70
+
71
+ return parentBase.join("/");
72
+ }
73
+
66
74
  requirejs._eak_seen = registry;
67
75
 
68
76
  Ember.__loader = {define: enifed, require: eriuqer, registry: registry};
@@ -7222,6 +7230,14 @@ enifed("ember-handlebars/tests/handlebars_test",
7222
7230
  ok(safeString instanceof Handlebars.SafeString, "should return SafeString");
7223
7231
  });
7224
7232
 
7233
+ test("htmlSafe should return an empty string for null", function() {
7234
+ equal(htmlSafe(null).toString(), "", "should return an empty string");
7235
+ });
7236
+
7237
+ test("htmlSafe should return an empty string for undefined", function() {
7238
+ equal(htmlSafe().toString(), "", "should return an empty string");
7239
+ });
7240
+
7225
7241
  test("should escape HTML in normal mustaches", function() {
7226
7242
  view = EmberView.create({
7227
7243
  template: EmberHandlebars.compile('{{view.output}}'),
@@ -27781,6 +27797,31 @@ enifed("ember-routing/tests/system/route_test",
27781
27797
  equal(route.modelFor('foo'), foo);
27782
27798
  });
27783
27799
 
27800
+
27801
+ test(".send just calls an action if the router is absent", function() {
27802
+ expect(7);
27803
+ var route = Ember.Route.createWithMixins({
27804
+ actions: {
27805
+ returnsTrue: function(foo, bar) {
27806
+ equal(foo, 1);
27807
+ equal(bar, 2);
27808
+ equal(this, route);
27809
+ return true;
27810
+ },
27811
+
27812
+ returnsFalse: function() {
27813
+ ok(true, "returnsFalse was called");
27814
+ return false;
27815
+ }
27816
+ }
27817
+ });
27818
+
27819
+ equal(true, route.send('returnsTrue', 1, 2));
27820
+ equal(false, route.send('returnsFalse'));
27821
+ equal(undefined, route.send('nonexistent', 1, 2, 3));
27822
+ });
27823
+
27824
+
27784
27825
  QUnit.module("Ember.Route serialize", {
27785
27826
  setup: createRoute,
27786
27827
  teardown: cleanupRoute
@@ -47989,6 +48030,27 @@ enifed("ember-views/tests/system/view_utils_test",
47989
48030
  var run = __dependency1__["default"];
47990
48031
  var View = __dependency2__["default"];
47991
48032
 
48033
+ var hasGetClientRects, hasGetBoundingClientRect;
48034
+ var ClientRectListCtor, ClientRectCtor;
48035
+
48036
+ (function() {
48037
+ if (document.createRange) {
48038
+ var range = document.createRange();
48039
+
48040
+ if (range.getClientRects) {
48041
+ var clientRectsList = range.getClientRects();
48042
+ hasGetClientRects = true;
48043
+ ClientRectListCtor = clientRectsList && clientRectsList.constructor;
48044
+ }
48045
+
48046
+ if (range.getBoundingClientRect) {
48047
+ var clientRect = range.getBoundingClientRect();
48048
+ hasGetBoundingClientRect = true;
48049
+ ClientRectCtor = clientRect && clientRect.constructor;
48050
+ }
48051
+ }
48052
+ })();
48053
+
47992
48054
  var view;
47993
48055
 
47994
48056
  QUnit.module("ViewUtils", {
@@ -47999,9 +48061,10 @@ enifed("ember-views/tests/system/view_utils_test",
47999
48061
  }
48000
48062
  });
48001
48063
 
48064
+
48002
48065
  test("getViewClientRects", function() {
48003
- if (!(window.Range && window.Range.prototype.getClientRects)) {
48004
- ok(true, "The test environment does not support the DOM API required for getViewClientRects.");
48066
+ if (!hasGetClientRects || !ClientRectListCtor) {
48067
+ ok(true, "The test environment does not support the DOM API required to run this test.");
48005
48068
  return;
48006
48069
  }
48007
48070
 
@@ -48013,12 +48076,12 @@ enifed("ember-views/tests/system/view_utils_test",
48013
48076
 
48014
48077
  run(function() { view.appendTo('#qunit-fixture'); });
48015
48078
 
48016
- ok(Ember.ViewUtils.getViewClientRects(view) instanceof window.ClientRectList);
48079
+ ok(Ember.ViewUtils.getViewClientRects(view) instanceof ClientRectListCtor);
48017
48080
  });
48018
48081
 
48019
48082
  test("getViewBoundingClientRect", function() {
48020
- if (!(window.Range && window.Range.prototype.getBoundingClientRect)) {
48021
- ok(true, "The test environment does not support the DOM API required for getViewBoundingClientRect.");
48083
+ if (!hasGetBoundingClientRect || !ClientRectCtor) {
48084
+ ok(true, "The test environment does not support the DOM API required to run this test.");
48022
48085
  return;
48023
48086
  }
48024
48087
 
@@ -48030,7 +48093,7 @@ enifed("ember-views/tests/system/view_utils_test",
48030
48093
 
48031
48094
  run(function() { view.appendTo('#qunit-fixture'); });
48032
48095
 
48033
- ok(Ember.ViewUtils.getViewBoundingClientRect(view) instanceof window.ClientRect);
48096
+ ok(Ember.ViewUtils.getViewBoundingClientRect(view) instanceof ClientRectCtor);
48034
48097
  });
48035
48098
  });
48036
48099
  enifed("ember-views/tests/system/view_utils_test.jshint",
@@ -59826,6 +59889,79 @@ enifed("ember/tests/routing/basic_test",
59826
59889
  Ember.run(router, 'transitionTo', 'out');
59827
59890
  deepEqual(calls, [['reset', 'c'], ['reset', 'a'], ['setup', 'out']]);
59828
59891
  });
59892
+
59893
+ test("Exception during initialization of non-initial route is not swallowed", function() {
59894
+ Router.map(function() {
59895
+ this.route('boom');
59896
+ });
59897
+ App.BoomRoute = Ember.Route.extend({
59898
+ init: function() {
59899
+ throw new Error("boom!");
59900
+ }
59901
+ });
59902
+ bootApplication();
59903
+ throws(function(){
59904
+ Ember.run(router, 'transitionTo', 'boom');
59905
+ }, /\bboom\b/);
59906
+ });
59907
+
59908
+
59909
+ test("Exception during load of non-initial route is not swallowed", function() {
59910
+ Router.map(function() {
59911
+ this.route('boom');
59912
+ });
59913
+ var lookup = container.lookup;
59914
+ container.lookup = function() {
59915
+ if (arguments[0] === 'route:boom') {
59916
+ throw new Error("boom!");
59917
+ }
59918
+ return lookup.apply(this, arguments);
59919
+ };
59920
+ App.BoomRoute = Ember.Route.extend({
59921
+ init: function() {
59922
+ throw new Error("boom!");
59923
+ }
59924
+ });
59925
+ bootApplication();
59926
+ throws(function(){
59927
+ Ember.run(router, 'transitionTo', 'boom');
59928
+ });
59929
+ });
59930
+
59931
+ test("Exception during initialization of initial route is not swallowed", function() {
59932
+ Router.map(function() {
59933
+ this.route('boom', {path: '/'});
59934
+ });
59935
+ App.BoomRoute = Ember.Route.extend({
59936
+ init: function() {
59937
+ throw new Error("boom!");
59938
+ }
59939
+ });
59940
+ throws(function(){
59941
+ bootApplication();
59942
+ }, /\bboom\b/);
59943
+ });
59944
+
59945
+ test("Exception during load of initial route is not swallowed", function() {
59946
+ Router.map(function() {
59947
+ this.route('boom', {path: '/'});
59948
+ });
59949
+ var lookup = container.lookup;
59950
+ container.lookup = function() {
59951
+ if (arguments[0] === 'route:boom') {
59952
+ throw new Error("boom!");
59953
+ }
59954
+ return lookup.apply(this, arguments);
59955
+ };
59956
+ App.BoomRoute = Ember.Route.extend({
59957
+ init: function() {
59958
+ throw new Error("boom!");
59959
+ }
59960
+ });
59961
+ throws(function(){
59962
+ bootApplication();
59963
+ }, /\bboom\b/);
59964
+ });
59829
59965
  });
59830
59966
  enifed("ember/tests/routing/basic_test.jshint",
59831
59967
  [],
@@ -5,7 +5,7 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 1.9.0-beta.4
8
+ * @version 1.9.0
9
9
  */
10
10
 
11
11
  (function() {
@@ -14,6 +14,7 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
14
14
  (function() {
15
15
  Ember = this.Ember = this.Ember || {};
16
16
  if (typeof Ember === 'undefined') { Ember = {}; };
17
+ function UNDEFINED() { }
17
18
 
18
19
  if (typeof Ember.__loader === 'undefined') {
19
20
  var registry = {}, seen = {};
@@ -23,7 +24,11 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
23
24
  };
24
25
 
25
26
  requirejs = eriuqer = requireModule = function(name) {
26
- if (seen.hasOwnProperty(name)) { return seen[name]; }
27
+ var s = seen[name];
28
+
29
+ if (s !== undefined) { return seen[name]; }
30
+ if (s === UNDEFINED) { return undefined; }
31
+
27
32
  seen[name] = {};
28
33
 
29
34
  if (!registry[name]) {
@@ -35,34 +40,37 @@ var enifed, requireModule, eriuqer, requirejs, Ember;
35
40
  var callback = mod.callback;
36
41
  var reified = [];
37
42
  var exports;
43
+ var length = deps.length;
38
44
 
39
- for (var i=0, l=deps.length; i<l; i++) {
45
+ for (var i=0; i<length; i++) {
40
46
  if (deps[i] === 'exports') {
41
47
  reified.push(exports = {});
42
48
  } else {
43
- reified.push(requireModule(resolve(deps[i])));
49
+ reified.push(requireModule(resolve(deps[i], name)));
44
50
  }
45
51
  }
46
52
 
47
- var value = callback.apply(this, reified);
48
- return seen[name] = exports || value;
53
+ var value = length === 0 ? callback.call(this) : callback.apply(this, reified);
49
54
 
50
- function resolve(child) {
51
- if (child.charAt(0) !== '.') { return child; }
52
- var parts = child.split("/");
53
- var parentBase = name.split("/").slice(0, -1);
55
+ return seen[name] = exports || (value === undefined ? UNDEFINED : value);
56
+ };
54
57
 
55
- for (var i=0, l=parts.length; i<l; i++) {
56
- var part = parts[i];
58
+ function resolve(child, name) {
59
+ if (child.charAt(0) !== '.') { return child; }
60
+ var parts = child.split("/");
61
+ var parentBase = name.split("/").slice(0, -1);
57
62
 
58
- if (part === '..') { parentBase.pop(); }
59
- else if (part === '.') { continue; }
60
- else { parentBase.push(part); }
61
- }
63
+ for (var i=0, l=parts.length; i<l; i++) {
64
+ var part = parts[i];
62
65
 
63
- return parentBase.join("/");
66
+ if (part === '..') { parentBase.pop(); }
67
+ else if (part === '.') { continue; }
68
+ else { parentBase.push(part); }
64
69
  }
65
- };
70
+
71
+ return parentBase.join("/");
72
+ }
73
+
66
74
  requirejs._eak_seen = registry;
67
75
 
68
76
  Ember.__loader = {define: enifed, require: eriuqer, registry: registry};
@@ -9610,6 +9618,10 @@ enifed("ember-handlebars/string",
9610
9618
  @return {Handlebars.SafeString} a string that will not be html escaped by Handlebars
9611
9619
  */
9612
9620
  function htmlSafe(str) {
9621
+ if (str === null || str === undefined) {
9622
+ return "";
9623
+ }
9624
+
9613
9625
  if (typeof str !== 'string') {
9614
9626
  str = ''+str;
9615
9627
  }
@@ -13122,7 +13134,7 @@ enifed("ember-metal/core",
13122
13134
 
13123
13135
  @class Ember
13124
13136
  @static
13125
- @version 1.9.0-beta.4
13137
+ @version 1.9.0
13126
13138
  */
13127
13139
 
13128
13140
  if ('undefined' === typeof Ember) {
@@ -13149,10 +13161,10 @@ enifed("ember-metal/core",
13149
13161
  /**
13150
13162
  @property VERSION
13151
13163
  @type String
13152
- @default '1.9.0-beta.4'
13164
+ @default '1.9.0'
13153
13165
  @static
13154
13166
  */
13155
- Ember.VERSION = '1.9.0-beta.4';
13167
+ Ember.VERSION = '1.9.0';
13156
13168
 
13157
13169
  /**
13158
13170
  Standard environmental variables. You can define these in a global `EmberENV`
@@ -17926,34 +17938,40 @@ enifed("ember-metal/run_loop",
17926
17938
  };
17927
17939
 
17928
17940
  /**
17929
- Provides a useful utility for when integrating with non-Ember libraries
17930
- that provide asynchronous callbacks.
17931
-
17932
- Ember utilizes a run-loop to batch and coalesce changes. This works by
17933
- marking the start and end of Ember-related Javascript execution.
17941
+ Allows you to specify which context to call the specified function in while
17942
+ adding the execution of that function to the Ember run loop. This ability
17943
+ makes this method a great way to asynchronusly integrate third-party libraries
17944
+ into your Ember application.
17934
17945
 
17935
- When using events such as a View's click handler, Ember wraps the event
17936
- handler in a run-loop, but when integrating with non-Ember libraries this
17937
- can be tedious.
17946
+ `run.bind` takes two main arguments, the desired context and the function to
17947
+ invoke in that context. Any additional arguments will be supplied as arguments
17948
+ to the function that is passed in.
17938
17949
 
17939
- For example, the following is rather verbose but is the correct way to combine
17940
- third-party events and Ember code.
17950
+ Let's use the creation of a TinyMCE component as an example. Currently,
17951
+ TinyMCE provides a setup configuration option we can use to do some processing
17952
+ after the TinyMCE instance is initialized but before it is actually rendered.
17953
+ We can use that setup option to do some additional setup for our component.
17954
+ The component itself could look something like the following:
17941
17955
 
17942
17956
  ```javascript
17943
- var that = this;
17944
- jQuery(window).on('resize', function(){
17945
- run(function(){
17946
- that.handleResize();
17947
- });
17957
+ App.RichTextEditorComponent = Ember.Component.extend({
17958
+ initializeTinyMCE: function(){
17959
+ tinymce.init({
17960
+ selector: '#' + this.$().prop('id'),
17961
+ setup: Ember.run.bind(this, this.setupEditor)
17962
+ });
17963
+ }.on('didInsertElement'),
17964
+
17965
+ setupEditor: function(editor) {
17966
+ this.set('editor', editor);
17967
+ editor.on('change', function(){ console.log('content changed!')} );
17968
+ }
17948
17969
  });
17949
17970
  ```
17950
17971
 
17951
- To reduce the boilerplate, the following can be used to construct a
17952
- run-loop-wrapped callback handler.
17953
-
17954
- ```javascript
17955
- jQuery(window).on('resize', run.bind(this, this.handleResize));
17956
- ```
17972
+ In this example, we use Ember.run.bind to bind the setupEditor message to the
17973
+ context of the App.RichTextEditorComponent and to have the invocation of that
17974
+ method be safely handled and excuted by the Ember run loop.
17957
17975
 
17958
17976
  @method bind
17959
17977
  @namespace Ember
@@ -17966,7 +17984,7 @@ enifed("ember-metal/run_loop",
17966
17984
  when called within an existing loop, no return value is possible.
17967
17985
  @since 1.4.0
17968
17986
  */
17969
- run.bind = function(target, method /* args*/) {
17987
+ run.bind = function(target, method /* args */) {
17970
17988
  var args = slice.call(arguments);
17971
17989
  return function() {
17972
17990
  return run.join.apply(run, args.concat(slice.call(arguments)));
@@ -23552,6 +23570,8 @@ enifed("ember-routing/system/route",
23552
23570
  var generateController = __dependency18__["default"];
23553
23571
  var stashParamNames = __dependency19__.stashParamNames;
23554
23572
 
23573
+ var slice = Array.prototype.slice;
23574
+
23555
23575
  /**
23556
23576
  @module ember
23557
23577
  @submodule ember-routing
@@ -24514,7 +24534,16 @@ enifed("ember-routing/system/route",
24514
24534
  @param {...*} args
24515
24535
  */
24516
24536
  send: function() {
24517
- return this.router.send.apply(this.router, arguments);
24537
+ if (this.router || !Ember.testing) {
24538
+ this.router.send.apply(this.router, arguments);
24539
+ } else {
24540
+ var name = arguments[0];
24541
+ var args = slice.call(arguments, 1);
24542
+ var action = this._actions[name];
24543
+ if (action) {
24544
+ return this._actions[name].apply(this, args);
24545
+ }
24546
+ }
24518
24547
  },
24519
24548
 
24520
24549
  /**
@@ -25678,6 +25707,7 @@ enifed("ember-routing/system/router",
25678
25707
  var container = this.container;
25679
25708
  var self = this;
25680
25709
  var initialURL = get(this, 'initialURL');
25710
+ var initialTransition;
25681
25711
 
25682
25712
  // Allow the Location class to cancel the router setup while it refreshes
25683
25713
  // the page
@@ -25697,8 +25727,10 @@ enifed("ember-routing/system/router",
25697
25727
  if (typeof initialURL === "undefined") {
25698
25728
  initialURL = location.getURL();
25699
25729
  }
25700
-
25701
- this.handleURL(initialURL);
25730
+ initialTransition = this.handleURL(initialURL);
25731
+ if (initialTransition && initialTransition.error) {
25732
+ throw initialTransition.error;
25733
+ }
25702
25734
  },
25703
25735
 
25704
25736
  /**
@@ -47052,6 +47084,7 @@ enifed("router/transition",
47052
47084
 
47053
47085
  if (error) {
47054
47086
  this.promise = Promise.reject(error);
47087
+ this.error = error;
47055
47088
  return;
47056
47089
  }
47057
47090