ember-source 2.7.0 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.7.0
9
+ * @version 2.7.2
10
10
  */
11
11
 
12
12
  var enifed, requireModule, require, Ember;
@@ -6602,13 +6602,16 @@ enifed('ember-debug/deprecate', ['exports', 'ember-metal/error', 'ember-console'
6602
6602
 
6603
6603
  @method deprecate
6604
6604
  @param {String} message A description of the deprecation.
6605
- @param {Boolean} test A boolean. If falsy, the deprecation
6606
- will be displayed.
6607
- @param {Object} options An object that can be used to pass
6608
- in a `url` to the transition guide on the emberjs.com website, and a unique
6609
- `id` for this deprecation. The `id` can be used by Ember debugging tools
6610
- to change the behavior (raise, log or silence) for that specific deprecation.
6611
- The `id` should be namespaced by dots, e.g. "view.helper.select".
6605
+ @param {Boolean} test A boolean. If falsy, the deprecation will be displayed.
6606
+ @param {Object} options
6607
+ @param {String} options.id A unique id for this deprecation. The id can be
6608
+ used by Ember debugging tools to change the behavior (raise, log or silence)
6609
+ for that specific deprecation. The id should be namespaced by dots, e.g.
6610
+ "view.helper.select".
6611
+ @param {string} options.until The version of Ember when this deprecation
6612
+ warning will be removed.
6613
+ @param {String} [options.url] An optional url to the transition guide on the
6614
+ emberjs.com website.
6612
6615
  @for Ember
6613
6616
  @public
6614
6617
  */
@@ -9669,7 +9672,7 @@ enifed('ember-htmlbars/components/link-to', ['exports', 'ember-console', 'ember-
9669
9672
  if (lastParam && lastParam.isQueryParams) {
9670
9673
  queryParams = params.pop();
9671
9674
  } else {
9672
- queryParams = {};
9675
+ queryParams = { values: {} };
9673
9676
  }
9674
9677
  this.set('queryParams', queryParams);
9675
9678
 
@@ -10866,7 +10869,7 @@ enifed('ember-htmlbars/hooks/component', ['exports', 'ember-metal/debug', 'ember
10866
10869
  var templateMeta = null;
10867
10870
  if (sm.block) {
10868
10871
  templateMeta = sm.block.template.meta;
10869
- } else if (sm.scope && sm.scope._view) {
10872
+ } else if (sm.scope && sm.scope._view && sm.scope._view.template) {
10870
10873
  templateMeta = sm.scope._view.template.meta;
10871
10874
  }
10872
10875
  env.meta.moduleName = templateMeta && templateMeta.moduleName || env.meta && env.meta.moduleName;
@@ -13456,12 +13459,12 @@ enifed('ember-htmlbars/keywords/partial', ['exports', 'ember-views/system/lookup
13456
13459
  ```
13457
13460
 
13458
13461
  The above example template will render a template named
13459
- "_nav", which has the same context as the parent template
13460
- it's rendered into, so if the "_nav" template also referenced
13462
+ "-nav", which has the same context as the parent template
13463
+ it's rendered into, so if the "-nav" template also referenced
13461
13464
  `{{foo}}`, it would print the same thing as the `{{foo}}`
13462
13465
  in the above example.
13463
13466
 
13464
- If a "_nav" template isn't found, the `partial` helper will
13467
+ If a "-nav" template isn't found, the `partial` helper will
13465
13468
  fall back to a template named "nav".
13466
13469
 
13467
13470
  ### Bound template names
@@ -18105,7 +18108,7 @@ enifed('ember-metal/binding', ['exports', 'ember-console', 'ember-environment',
18105
18108
 
18106
18109
  _emberMetalEvents.addListener(obj, 'willDestroy', this, 'disconnect');
18107
18110
 
18108
- fireDeprecations(possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay);
18111
+ fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay);
18109
18112
 
18110
18113
  this._readyToSync = true;
18111
18114
  this._fromObj = fromObj;
@@ -18214,22 +18217,23 @@ enifed('ember-metal/binding', ['exports', 'ember-console', 'ember-environment',
18214
18217
 
18215
18218
  };
18216
18219
 
18217
- function fireDeprecations(deprecateGlobal, deprecateOneWay, deprecateAlias) {
18220
+ function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) {
18218
18221
  var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.';
18219
18222
  var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.';
18220
18223
  var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.';
18221
18224
 
18222
- _emberMetalDebug.deprecate(deprecateGlobalMessage, !deprecateGlobal, {
18225
+ var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but ';
18226
+ _emberMetalDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, {
18223
18227
  id: 'ember-metal.binding',
18224
18228
  until: '3.0.0',
18225
18229
  url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding'
18226
18230
  });
18227
- _emberMetalDebug.deprecate(deprecateOneWayMessage, !deprecateOneWay, {
18231
+ _emberMetalDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, {
18228
18232
  id: 'ember-metal.binding',
18229
18233
  until: '3.0.0',
18230
18234
  url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding'
18231
18235
  });
18232
- _emberMetalDebug.deprecate(deprecateAliasMessage, !deprecateAlias, {
18236
+ _emberMetalDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, {
18233
18237
  id: 'ember-metal.binding',
18234
18238
  until: '3.0.0',
18235
18239
  url: 'http://emberjs.com/deprecations/v2.x#toc_ember-binding'
@@ -28295,7 +28299,7 @@ enifed('ember-routing/system/route', ['exports', 'ember-metal/debug', 'ember-met
28295
28299
  This action is called when one or more query params have changed. Bubbles.
28296
28300
  @method queryParamsDidChange
28297
28301
  @param changed {Object} Keys are names of query params that have changed.
28298
- @param totalPresent {Number}
28302
+ @param totalPresent {Object} Keys are names of query params that are currently set.
28299
28303
  @param removed {Object} Keys are names of query params that have been removed.
28300
28304
  @returns {boolean}
28301
28305
  @private
@@ -34991,7 +34995,7 @@ enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-metal/property_get'
34991
34995
 
34992
34996
  /**
34993
34997
  Sets the value on the named property for each member. This is more
34994
- efficient than using other methods defined on this helper. If the object
34998
+ ergonomic than using other methods defined on this helper. If the object
34995
34999
  implements Ember.Observable, the value will be changed to `set(),` otherwise
34996
35000
  it will be set directly. `null` objects are skipped.
34997
35001
  @method setEach
@@ -41303,6 +41307,7 @@ enifed('ember-testing/helpers', ['exports', 'ember-testing/test/helpers', 'ember
41303
41307
 
41304
41308
  @method click
41305
41309
  @param {String} selector jQuery selector for finding element on the DOM
41310
+ @param {Object} context A DOM Element, Document, or jQuery to use as context
41306
41311
  @return {RSVP.Promise}
41307
41312
  @public
41308
41313
  */
@@ -45324,7 +45329,7 @@ enifed('ember-views/views/view', ['exports', 'ember-views/system/ext', 'ember-vi
45324
45329
  ```
45325
45330
 
45326
45331
  If the return value of an `attributeBindings` monitored property is a boolean
45327
- the property's value will be set as a coerced string:
45332
+ the attribute will be present or absent depending on the value:
45328
45333
 
45329
45334
  ```javascript
45330
45335
  MyTextInput = Ember.View.extend({
@@ -45337,7 +45342,7 @@ enifed('ember-views/views/view', ['exports', 'ember-views/system/ext', 'ember-vi
45337
45342
  Will result in a view instance with an HTML representation of:
45338
45343
 
45339
45344
  ```html
45340
- <input id="ember1" class="ember-view" disabled="false" />
45345
+ <input id="ember1" class="ember-view" />
45341
45346
  ```
45342
45347
 
45343
45348
  `attributeBindings` can refer to computed properties:
@@ -45806,7 +45811,7 @@ enifed('ember/index', ['exports', 'ember-metal', 'ember-runtime', 'ember-views',
45806
45811
  enifed("ember/version", ["exports"], function (exports) {
45807
45812
  "use strict";
45808
45813
 
45809
- exports.default = "2.7.0";
45814
+ exports.default = "2.7.2";
45810
45815
  });
45811
45816
  enifed('htmlbars-runtime', ['exports', 'htmlbars-runtime/hooks', 'htmlbars-runtime/render', 'htmlbars-util/morph-utils', 'htmlbars-util/template-utils'], function (exports, _htmlbarsRuntimeHooks, _htmlbarsRuntimeRender, _htmlbarsUtilMorphUtils, _htmlbarsUtilTemplateUtils) {
45812
45817
  'use strict';
@@ -49015,12 +49020,9 @@ enifed("morph-range/utils", ["exports"], function (exports) {
49015
49020
  } while (node);
49016
49021
  }
49017
49022
  });
49018
- enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer/normalizer'], function (exports, _routeRecognizerDsl, _routeRecognizerNormalizer) {
49023
+ enifed('route-recognizer', ['exports', 'route-recognizer/dsl'], function (exports, _routeRecognizerDsl) {
49019
49024
  'use strict';
49020
49025
 
49021
- var normalizePath = _routeRecognizerNormalizer.default.normalizePath;
49022
- var normalizeSegment = _routeRecognizerNormalizer.default.normalizeSegment;
49023
-
49024
49026
  var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
49025
49027
 
49026
49028
  var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
@@ -49047,19 +49049,17 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49047
49049
  // * `repeat`: true if the character specification can repeat
49048
49050
 
49049
49051
  function StaticSegment(string) {
49050
- this.string = normalizeSegment(string);
49052
+ this.string = string;
49051
49053
  }
49052
49054
  StaticSegment.prototype = {
49053
- eachChar: function (currentState) {
49055
+ eachChar: function (callback) {
49054
49056
  var string = this.string,
49055
49057
  ch;
49056
49058
 
49057
- for (var i = 0; i < string.length; i++) {
49059
+ for (var i = 0, l = string.length; i < l; i++) {
49058
49060
  ch = string.charAt(i);
49059
- currentState = currentState.put({ invalidChars: undefined, repeat: false, validChars: ch });
49061
+ callback({ validChars: ch });
49060
49062
  }
49061
-
49062
- return currentState;
49063
49063
  },
49064
49064
 
49065
49065
  regex: function () {
@@ -49072,11 +49072,11 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49072
49072
  };
49073
49073
 
49074
49074
  function DynamicSegment(name) {
49075
- this.name = normalizeSegment(name);
49075
+ this.name = name;
49076
49076
  }
49077
49077
  DynamicSegment.prototype = {
49078
- eachChar: function (currentState) {
49079
- return currentState.put({ invalidChars: "/", repeat: true, validChars: undefined });
49078
+ eachChar: function (callback) {
49079
+ callback({ invalidChars: "/", repeat: true });
49080
49080
  },
49081
49081
 
49082
49082
  regex: function () {
@@ -49084,11 +49084,7 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49084
49084
  },
49085
49085
 
49086
49086
  generate: function (params) {
49087
- if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
49088
- return encodeURIComponent(params[this.name]);
49089
- } else {
49090
- return params[this.name];
49091
- }
49087
+ return params[this.name];
49092
49088
  }
49093
49089
  };
49094
49090
 
@@ -49096,8 +49092,8 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49096
49092
  this.name = name;
49097
49093
  }
49098
49094
  StarSegment.prototype = {
49099
- eachChar: function (currentState) {
49100
- return currentState.put({ invalidChars: "", repeat: true, validChars: undefined });
49095
+ eachChar: function (callback) {
49096
+ callback({ invalidChars: "", repeat: true });
49101
49097
  },
49102
49098
 
49103
49099
  regex: function () {
@@ -49111,9 +49107,7 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49111
49107
 
49112
49108
  function EpsilonSegment() {}
49113
49109
  EpsilonSegment.prototype = {
49114
- eachChar: function (currentState) {
49115
- return currentState;
49116
- },
49110
+ eachChar: function () {},
49117
49111
  regex: function () {
49118
49112
  return "";
49119
49113
  },
@@ -49122,65 +49116,36 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49122
49116
  }
49123
49117
  };
49124
49118
 
49125
- // The `names` will be populated with the paramter name for each dynamic/star
49126
- // segment. `shouldDecodes` will be populated with a boolean for each dyanamic/star
49127
- // segment, indicating whether it should be decoded during recognition.
49128
- function parse(route, names, specificity, shouldDecodes) {
49119
+ function parse(route, names, types) {
49129
49120
  // normalize route as not starting with a "/". Recognition will
49130
49121
  // also normalize.
49131
49122
  if (route.charAt(0) === "/") {
49132
49123
  route = route.substr(1);
49133
49124
  }
49134
49125
 
49135
- var segments = route.split("/");
49136
- var results = new Array(segments.length);
49137
-
49138
- // A routes has specificity determined by the order that its different segments
49139
- // appear in. This system mirrors how the magnitude of numbers written as strings
49140
- // works.
49141
- // Consider a number written as: "abc". An example would be "200". Any other number written
49142
- // "xyz" will be smaller than "abc" so long as `a > x`. For instance, "199" is smaller
49143
- // then "200", even though "y" and "z" (which are both 9) are larger than "0" (the value
49144
- // of (`b` and `c`). This is because the leading symbol, "2", is larger than the other
49145
- // leading symbol, "1".
49146
- // The rule is that symbols to the left carry more weight than symbols to the right
49147
- // when a number is written out as a string. In the above strings, the leading digit
49148
- // represents how many 100's are in the number, and it carries more weight than the middle
49149
- // number which represents how many 10's are in the number.
49150
- // This system of number magnitude works well for route specificity, too. A route written as
49151
- // `a/b/c` will be more specific than `x/y/z` as long as `a` is more specific than
49152
- // `x`, irrespective of the other parts.
49153
- // Because of this similarity, we assign each type of segment a number value written as a
49154
- // string. We can find the specificity of compound routes by concatenating these strings
49155
- // together, from left to right. After we have looped through all of the segments,
49156
- // we convert the string to a number.
49157
- specificity.val = '';
49126
+ var segments = route.split("/"),
49127
+ results = [];
49158
49128
 
49159
- for (var i = 0; i < segments.length; i++) {
49129
+ for (var i = 0, l = segments.length; i < l; i++) {
49160
49130
  var segment = segments[i],
49161
49131
  match;
49162
49132
 
49163
49133
  if (match = segment.match(/^:([^\/]+)$/)) {
49164
- results[i] = new DynamicSegment(match[1]);
49134
+ results.push(new DynamicSegment(match[1]));
49165
49135
  names.push(match[1]);
49166
- shouldDecodes.push(true);
49167
- specificity.val += '3';
49136
+ types.dynamics++;
49168
49137
  } else if (match = segment.match(/^\*([^\/]+)$/)) {
49169
- results[i] = new StarSegment(match[1]);
49138
+ results.push(new StarSegment(match[1]));
49170
49139
  names.push(match[1]);
49171
- shouldDecodes.push(false);
49172
- specificity.val += '1';
49140
+ types.stars++;
49173
49141
  } else if (segment === "") {
49174
- results[i] = new EpsilonSegment();
49175
- specificity.val += '2';
49142
+ results.push(new EpsilonSegment());
49176
49143
  } else {
49177
- results[i] = new StaticSegment(segment);
49178
- specificity.val += '4';
49144
+ results.push(new StaticSegment(segment));
49145
+ types.statics++;
49179
49146
  }
49180
49147
  }
49181
49148
 
49182
- specificity.val = +specificity.val;
49183
-
49184
49149
  return results;
49185
49150
  }
49186
49151
 
@@ -49204,28 +49169,19 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49204
49169
  function State(charSpec) {
49205
49170
  this.charSpec = charSpec;
49206
49171
  this.nextStates = [];
49207
- this.charSpecs = {};
49208
- this.regex = undefined;
49209
- this.handlers = undefined;
49210
- this.specificity = undefined;
49211
49172
  }
49212
49173
 
49213
49174
  State.prototype = {
49214
49175
  get: function (charSpec) {
49215
- if (this.charSpecs[charSpec.validChars]) {
49216
- return this.charSpecs[charSpec.validChars];
49217
- }
49218
-
49219
49176
  var nextStates = this.nextStates;
49220
49177
 
49221
- for (var i = 0; i < nextStates.length; i++) {
49178
+ for (var i = 0, l = nextStates.length; i < l; i++) {
49222
49179
  var child = nextStates[i];
49223
49180
 
49224
49181
  var isEqual = child.charSpec.validChars === charSpec.validChars;
49225
49182
  isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars;
49226
49183
 
49227
49184
  if (isEqual) {
49228
- this.charSpecs[charSpec.validChars] = child;
49229
49185
  return child;
49230
49186
  }
49231
49187
  }
@@ -49259,14 +49215,16 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49259
49215
 
49260
49216
  // Find a list of child states matching the next character
49261
49217
  match: function (ch) {
49218
+ // DEBUG "Processing `" + ch + "`:"
49262
49219
  var nextStates = this.nextStates,
49263
49220
  child,
49264
49221
  charSpec,
49265
49222
  chars;
49266
49223
 
49224
+ // DEBUG " " + debugState(this)
49267
49225
  var returned = [];
49268
49226
 
49269
- for (var i = 0; i < nextStates.length; i++) {
49227
+ for (var i = 0, l = nextStates.length; i < l; i++) {
49270
49228
  child = nextStates[i];
49271
49229
 
49272
49230
  charSpec = child.charSpec;
@@ -49284,12 +49242,67 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49284
49242
 
49285
49243
  return returned;
49286
49244
  }
49245
+
49246
+ /** IF DEBUG
49247
+ , debug: function() {
49248
+ var charSpec = this.charSpec,
49249
+ debug = "[",
49250
+ chars = charSpec.validChars || charSpec.invalidChars;
49251
+ if (charSpec.invalidChars) { debug += "^"; }
49252
+ debug += chars;
49253
+ debug += "]";
49254
+ if (charSpec.repeat) { debug += "+"; }
49255
+ return debug;
49256
+ }
49257
+ END IF **/
49287
49258
  };
49288
49259
 
49289
- // Sort the routes by specificity
49260
+ /** IF DEBUG
49261
+ function debug(log) {
49262
+ console.log(log);
49263
+ }
49264
+
49265
+ function debugState(state) {
49266
+ return state.nextStates.map(function(n) {
49267
+ if (n.nextStates.length === 0) { return "( " + n.debug() + " [accepting] )"; }
49268
+ return "( " + n.debug() + " <then> " + n.nextStates.map(function(s) { return s.debug() }).join(" or ") + " )";
49269
+ }).join(", ")
49270
+ }
49271
+ END IF **/
49272
+
49273
+ // This is a somewhat naive strategy, but should work in a lot of cases
49274
+ // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.
49275
+ //
49276
+ // This strategy generally prefers more static and less dynamic matching.
49277
+ // Specifically, it
49278
+ //
49279
+ // * prefers fewer stars to more, then
49280
+ // * prefers using stars for less of the match to more, then
49281
+ // * prefers fewer dynamic segments to more, then
49282
+ // * prefers more static segments to more
49290
49283
  function sortSolutions(states) {
49291
49284
  return states.sort(function (a, b) {
49292
- return b.specificity.val - a.specificity.val;
49285
+ if (a.types.stars !== b.types.stars) {
49286
+ return a.types.stars - b.types.stars;
49287
+ }
49288
+
49289
+ if (a.types.stars) {
49290
+ if (a.types.statics !== b.types.statics) {
49291
+ return b.types.statics - a.types.statics;
49292
+ }
49293
+ if (a.types.dynamics !== b.types.dynamics) {
49294
+ return b.types.dynamics - a.types.dynamics;
49295
+ }
49296
+ }
49297
+
49298
+ if (a.types.dynamics !== b.types.dynamics) {
49299
+ return a.types.dynamics - b.types.dynamics;
49300
+ }
49301
+ if (a.types.statics !== b.types.statics) {
49302
+ return b.types.statics - a.types.statics;
49303
+ }
49304
+
49305
+ return 0;
49293
49306
  });
49294
49307
  }
49295
49308
 
@@ -49322,54 +49335,42 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49322
49335
  queryParams: null
49323
49336
  });
49324
49337
 
49325
- function findHandler(state, originalPath, queryParams) {
49338
+ function findHandler(state, path, queryParams) {
49326
49339
  var handlers = state.handlers,
49327
49340
  regex = state.regex;
49328
- var captures = originalPath.match(regex),
49341
+ var captures = path.match(regex),
49329
49342
  currentCapture = 1;
49330
49343
  var result = new RecognizeResults(queryParams);
49331
49344
 
49332
- result.length = handlers.length;
49333
-
49334
- for (var i = 0; i < handlers.length; i++) {
49345
+ for (var i = 0, l = handlers.length; i < l; i++) {
49335
49346
  var handler = handlers[i],
49336
49347
  names = handler.names,
49337
- shouldDecodes = handler.shouldDecodes,
49338
49348
  params = {};
49339
- var name, shouldDecode, capture;
49340
-
49341
- for (var j = 0; j < names.length; j++) {
49342
- name = names[j];
49343
- shouldDecode = shouldDecodes[j];
49344
- capture = captures[currentCapture++];
49345
49349
 
49346
- if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
49347
- if (shouldDecode) {
49348
- params[name] = decodeURIComponent(capture);
49349
- } else {
49350
- params[name] = capture;
49351
- }
49352
- } else {
49353
- params[name] = capture;
49354
- }
49350
+ for (var j = 0, m = names.length; j < m; j++) {
49351
+ params[names[j]] = captures[currentCapture++];
49355
49352
  }
49356
49353
 
49357
- result[i] = { handler: handler.handler, params: params, isDynamic: !!names.length };
49354
+ result.push({ handler: handler.handler, params: params, isDynamic: !!names.length });
49358
49355
  }
49359
49356
 
49360
49357
  return result;
49361
49358
  }
49362
49359
 
49360
+ function addSegment(currentState, segment) {
49361
+ segment.eachChar(function (ch) {
49362
+ var state;
49363
+
49364
+ currentState = currentState.put(ch);
49365
+ });
49366
+
49367
+ return currentState;
49368
+ }
49369
+
49363
49370
  function decodeQueryParamPart(part) {
49364
49371
  // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
49365
49372
  part = part.replace(/\+/gm, '%20');
49366
- var result;
49367
- try {
49368
- result = decodeURIComponent(part);
49369
- } catch (error) {
49370
- result = '';
49371
- }
49372
- return result;
49373
+ return decodeURIComponent(part);
49373
49374
  }
49374
49375
 
49375
49376
  // The main interface
@@ -49383,23 +49384,22 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49383
49384
  add: function (routes, options) {
49384
49385
  var currentState = this.rootState,
49385
49386
  regex = "^",
49386
- specificity = {},
49387
- handlers = new Array(routes.length),
49387
+ types = { statics: 0, dynamics: 0, stars: 0 },
49388
+ handlers = [],
49388
49389
  allSegments = [],
49389
49390
  name;
49390
49391
 
49391
49392
  var isEmpty = true;
49392
49393
 
49393
- for (var i = 0; i < routes.length; i++) {
49394
+ for (var i = 0, l = routes.length; i < l; i++) {
49394
49395
  var route = routes[i],
49395
- names = [],
49396
- shouldDecodes = [];
49396
+ names = [];
49397
49397
 
49398
- var segments = parse(route.path, names, specificity, shouldDecodes);
49398
+ var segments = parse(route.path, names, types);
49399
49399
 
49400
49400
  allSegments = allSegments.concat(segments);
49401
49401
 
49402
- for (var j = 0; j < segments.length; j++) {
49402
+ for (var j = 0, m = segments.length; j < m; j++) {
49403
49403
  var segment = segments[j];
49404
49404
 
49405
49405
  if (segment instanceof EpsilonSegment) {
@@ -49409,25 +49409,26 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49409
49409
  isEmpty = false;
49410
49410
 
49411
49411
  // Add a "/" for the new segment
49412
- currentState = currentState.put({ invalidChars: undefined, repeat: false, validChars: "/" });
49412
+ currentState = currentState.put({ validChars: "/" });
49413
49413
  regex += "/";
49414
49414
 
49415
49415
  // Add a representation of the segment to the NFA and regex
49416
- currentState = segment.eachChar(currentState);
49416
+ currentState = addSegment(currentState, segment);
49417
49417
  regex += segment.regex();
49418
49418
  }
49419
- var handler = { handler: route.handler, names: names, shouldDecodes: shouldDecodes };
49420
- handlers[i] = handler;
49419
+
49420
+ var handler = { handler: route.handler, names: names };
49421
+ handlers.push(handler);
49421
49422
  }
49422
49423
 
49423
49424
  if (isEmpty) {
49424
- currentState = currentState.put({ invalidChars: undefined, repeat: false, validChars: "/" });
49425
+ currentState = currentState.put({ validChars: "/" });
49425
49426
  regex += "/";
49426
49427
  }
49427
49428
 
49428
49429
  currentState.handlers = handlers;
49429
49430
  currentState.regex = new RegExp(regex + "$");
49430
- currentState.specificity = specificity;
49431
+ currentState.types = types;
49431
49432
 
49432
49433
  if (name = options && options.as) {
49433
49434
  this.names[name] = {
@@ -49438,16 +49439,14 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49438
49439
  },
49439
49440
 
49440
49441
  handlersFor: function (name) {
49441
- var route = this.names[name];
49442
-
49442
+ var route = this.names[name],
49443
+ result = [];
49443
49444
  if (!route) {
49444
49445
  throw new Error("There is no route named " + name);
49445
49446
  }
49446
49447
 
49447
- var result = new Array(route.handlers.length);
49448
-
49449
- for (var i = 0; i < route.handlers.length; i++) {
49450
- result[i] = route.handlers[i];
49448
+ for (var i = 0, l = route.handlers.length; i < l; i++) {
49449
+ result.push(route.handlers[i]);
49451
49450
  }
49452
49451
 
49453
49452
  return result;
@@ -49466,7 +49465,7 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49466
49465
 
49467
49466
  var segments = route.segments;
49468
49467
 
49469
- for (var i = 0; i < segments.length; i++) {
49468
+ for (var i = 0, l = segments.length; i < l; i++) {
49470
49469
  var segment = segments[i];
49471
49470
 
49472
49471
  if (segment instanceof EpsilonSegment) {
@@ -49497,7 +49496,7 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49497
49496
  }
49498
49497
  }
49499
49498
  keys.sort();
49500
- for (var i = 0; i < keys.length; i++) {
49499
+ for (var i = 0, len = keys.length; i < len; i++) {
49501
49500
  key = keys[i];
49502
49501
  var value = params[key];
49503
49502
  if (value == null) {
@@ -49505,7 +49504,7 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49505
49504
  }
49506
49505
  var pair = encodeURIComponent(key);
49507
49506
  if (isArray(value)) {
49508
- for (var j = 0; j < value.length; j++) {
49507
+ for (var j = 0, l = value.length; j < l; j++) {
49509
49508
  var arrayPair = key + '[]' + '=' + encodeURIComponent(value[j]);
49510
49509
  pairs.push(arrayPair);
49511
49510
  }
@@ -49560,14 +49559,8 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49560
49559
  l,
49561
49560
  queryStart,
49562
49561
  queryParams = {},
49563
- hashStart,
49564
49562
  isSlashDropped = false;
49565
49563
 
49566
- hashStart = path.indexOf('#');
49567
- if (hashStart !== -1) {
49568
- path = path.substr(0, hashStart);
49569
- }
49570
-
49571
49564
  queryStart = path.indexOf('?');
49572
49565
  if (queryStart !== -1) {
49573
49566
  var queryString = path.substr(queryStart + 1, path.length);
@@ -49575,34 +49568,31 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49575
49568
  queryParams = this.parseQueryString(queryString);
49576
49569
  }
49577
49570
 
49571
+ path = decodeURI(path);
49572
+
49573
+ // DEBUG GROUP path
49574
+
49578
49575
  if (path.charAt(0) !== "/") {
49579
49576
  path = "/" + path;
49580
49577
  }
49581
- var originalPath = path;
49582
-
49583
- if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
49584
- path = normalizePath(path);
49585
- } else {
49586
- path = decodeURI(path);
49587
- originalPath = decodeURI(originalPath);
49588
- }
49589
49578
 
49590
49579
  pathLen = path.length;
49591
49580
  if (pathLen > 1 && path.charAt(pathLen - 1) === "/") {
49592
49581
  path = path.substr(0, pathLen - 1);
49593
- originalPath = originalPath.substr(0, pathLen - 1);
49594
49582
  isSlashDropped = true;
49595
49583
  }
49596
49584
 
49597
- for (i = 0; i < path.length; i++) {
49585
+ for (i = 0, l = path.length; i < l; i++) {
49598
49586
  states = recognizeChar(states, path.charAt(i));
49599
49587
  if (!states.length) {
49600
49588
  break;
49601
49589
  }
49602
49590
  }
49603
49591
 
49592
+ // END DEBUG GROUP
49593
+
49604
49594
  var solutions = [];
49605
- for (i = 0; i < states.length; i++) {
49595
+ for (i = 0, l = states.length; i < l; i++) {
49606
49596
  if (states[i].handlers) {
49607
49597
  solutions.push(states[i]);
49608
49598
  }
@@ -49616,22 +49606,16 @@ enifed('route-recognizer', ['exports', 'route-recognizer/dsl', 'route-recognizer
49616
49606
  // if a trailing slash was dropped and a star segment is the last segment
49617
49607
  // specified, put the trailing slash back
49618
49608
  if (isSlashDropped && state.regex.source.slice(-5) === "(.+)$") {
49619
- originalPath = originalPath + "/";
49609
+ path = path + "/";
49620
49610
  }
49621
- return findHandler(state, originalPath, queryParams);
49611
+ return findHandler(state, path, queryParams);
49622
49612
  }
49623
49613
  }
49624
49614
  };
49625
49615
 
49626
49616
  RouteRecognizer.prototype.map = _routeRecognizerDsl.default;
49627
49617
 
49628
- RouteRecognizer.VERSION = '0.2.0';
49629
-
49630
- // Set to false to opt-out of encoding and decoding path segments.
49631
- // See https://github.com/tildeio/route-recognizer/pull/55
49632
- RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS = true;
49633
-
49634
- RouteRecognizer.Normalizer = _routeRecognizerNormalizer.default;
49618
+ RouteRecognizer.VERSION = '0.1.5';
49635
49619
 
49636
49620
  exports.default = RouteRecognizer;
49637
49621
  });
@@ -49703,7 +49687,7 @@ enifed("route-recognizer/dsl", ["exports"], function (exports) {
49703
49687
 
49704
49688
  function addRoute(routeArray, path, handler) {
49705
49689
  var len = 0;
49706
- for (var i = 0; i < routeArray.length; i++) {
49690
+ for (var i = 0, l = routeArray.length; i < l; i++) {
49707
49691
  len += routeArray[i].path.length;
49708
49692
  }
49709
49693
 
@@ -49743,94 +49727,6 @@ enifed("route-recognizer/dsl", ["exports"], function (exports) {
49743
49727
  }, this);
49744
49728
  };
49745
49729
  });
49746
- enifed('route-recognizer/normalizer', ['exports'], function (exports) {
49747
- // Match percent-encoded values (e.g. %3a, %3A, %25)
49748
- 'use strict';
49749
-
49750
- var PERCENT_ENCODED_VALUES = /%[a-fA-F0-9]{2}/g;
49751
-
49752
- function toUpper(str) {
49753
- return str.toUpperCase();
49754
- }
49755
-
49756
- // Turn percent-encoded values to upper case ("%3a" -> "%3A")
49757
- function percentEncodedValuesToUpper(string) {
49758
- return string.replace(PERCENT_ENCODED_VALUES, toUpper);
49759
- }
49760
-
49761
- // Normalizes percent-encoded values to upper-case and decodes percent-encoded
49762
- // values that are not reserved (like unicode characters).
49763
- // Safe to call multiple times on the same path.
49764
- function normalizePath(path) {
49765
- return path.split('/').map(normalizeSegment).join('/');
49766
- }
49767
-
49768
- function percentEncode(char) {
49769
- return '%' + charToHex(char);
49770
- }
49771
-
49772
- function charToHex(char) {
49773
- return char.charCodeAt(0).toString(16).toUpperCase();
49774
- }
49775
-
49776
- // Decodes percent-encoded values in the string except those
49777
- // characters in `reservedHex`, where `reservedHex` is an array of 2-character
49778
- // percent-encodings
49779
- function decodeURIComponentExcept(string, reservedHex) {
49780
- if (string.indexOf('%') === -1) {
49781
- // If there is no percent char, there is no decoding that needs to
49782
- // be done and we exit early
49783
- return string;
49784
- }
49785
- string = percentEncodedValuesToUpper(string);
49786
-
49787
- var result = '';
49788
- var buffer = '';
49789
- var idx = 0;
49790
- while (idx < string.length) {
49791
- var pIdx = string.indexOf('%', idx);
49792
-
49793
- if (pIdx === -1) {
49794
- // no percent char
49795
- buffer += string.slice(idx);
49796
- break;
49797
- } else {
49798
- // found percent char
49799
- buffer += string.slice(idx, pIdx);
49800
- idx = pIdx + 3;
49801
-
49802
- var hex = string.slice(pIdx + 1, pIdx + 3);
49803
- var encoded = '%' + hex;
49804
-
49805
- if (reservedHex.indexOf(hex) === -1) {
49806
- // encoded is not in reserved set, add to buffer
49807
- buffer += encoded;
49808
- } else {
49809
- result += decodeURIComponent(buffer);
49810
- buffer = '';
49811
- result += encoded;
49812
- }
49813
- }
49814
- }
49815
- result += decodeURIComponent(buffer);
49816
- return result;
49817
- }
49818
-
49819
- // Leave these characters in encoded state in segments
49820
- var reservedSegmentChars = ['%', '/'];
49821
- var reservedHex = reservedSegmentChars.map(charToHex);
49822
-
49823
- function normalizeSegment(segment) {
49824
- return decodeURIComponentExcept(segment, reservedHex);
49825
- }
49826
-
49827
- var Normalizer = {
49828
- normalizeSegment: normalizeSegment,
49829
- normalizePath: normalizePath
49830
- };
49831
-
49832
- exports.default = Normalizer;
49833
- });
49834
49730
  enifed('router', ['exports', 'router/router'], function (exports, _routerRouter) {
49835
49731
  'use strict';
49836
49732