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
2f5adaa7a2ed502932e33dc441d613098c6af79a.json
Render values with val. Fixes #1828 In jQuery 1.9, setting the value of an input with `attr(` is no longer supported. Here we explode `applyAttributeBindings` to handle value properties with `val(` instead. of `attr(`. This required adding an duck of value handling in jQuery to `RenderBuffer`
packages/ember-views/tests/system/render_buffer_test.js
@@ -48,6 +48,20 @@ test("prevents XSS injection via `attr`", function() { equal(el.childNodes.length, 0, 'should not have children'); }); +test("prevents XSS injection via `val`", function() { + var buffer = new Ember.RenderBuffer('input'); + + buffer.val('trololol" onmouseover="pwn()'); + buffer.pushOpeningTag(); + + var el = buffer.element(), + elValue = el.value, + elOnmouseover = el.getAttribute('onmouseover'); + + equal(elValue, 'trololol" onmouseover="pwn()', 'value should be escaped'); + equal(elOnmouseover, undefined, 'should not have onmouseover'); +}); + test("prevents XSS injection via `addClass`", function() { var buffer = new Ember.RenderBuffer('div');
true
Other
emberjs
ember.js
f3789b7acdd9c025c33b0519304036ebc11769ef.json
Add intersection to enumerable utils
packages/ember-metal/lib/array.js
@@ -1,4 +1,5 @@ /*jshint newcap:false*/ +require('ember-metal/enumerable_utils'); /** @module ember-metal @@ -77,46 +78,6 @@ Ember.ArrayPolyfills = { indexOf: arrayIndexOf }; -var utils = Ember.EnumerableUtils = { - map: function(obj, callback, thisArg) { - return obj.map ? obj.map.call(obj, callback, thisArg) : arrayMap.call(obj, callback, thisArg); - }, - - forEach: function(obj, callback, thisArg) { - return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : arrayForEach.call(obj, callback, thisArg); - }, - - indexOf: function(obj, element, index) { - return obj.indexOf ? obj.indexOf.call(obj, element, index) : arrayIndexOf.call(obj, element, index); - }, - - indexesOf: function(obj, elements) { - return elements === undefined ? [] : utils.map(elements, function(item) { - return utils.indexOf(obj, item); - }); - }, - - addObject: function(array, item) { - var index = utils.indexOf(array, item); - if (index === -1) { array.push(item); } - }, - - removeObject: function(array, item) { - var index = utils.indexOf(array, item); - if (index !== -1) { array.splice(index, 1); } - }, - - replace: function(array, idx, amt, objects) { - if (array.replace) { - return array.replace(idx, amt, objects); - } else { - var args = Array.prototype.concat.apply([idx, amt], objects); - return array.splice.apply(array, args); - } - } -}; - - if (Ember.SHIM_ES5) { if (!Array.prototype.map) { Array.prototype.map = arrayMap;
true
Other
emberjs
ember.js
f3789b7acdd9c025c33b0519304036ebc11769ef.json
Add intersection to enumerable utils
packages/ember-metal/lib/enumerable_utils.js
@@ -0,0 +1,50 @@ +var utils = Ember.EnumerableUtils = { + map: function(obj, callback, thisArg) { + return obj.map ? obj.map.call(obj, callback, thisArg) : Array.prototype.map.call(obj, callback, thisArg); + }, + + forEach: function(obj, callback, thisArg) { + return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : Array.prototype.forEach.call(obj, callback, thisArg); + }, + + indexOf: function(obj, element, index) { + return obj.indexOf ? obj.indexOf.call(obj, element, index) : Array.prototype.indexOf.call(obj, element, index); + }, + + indexesOf: function(obj, elements) { + return elements === undefined ? [] : utils.map(elements, function(item) { + return utils.indexOf(obj, item); + }); + }, + + addObject: function(array, item) { + var index = utils.indexOf(array, item); + if (index === -1) { array.push(item); } + }, + + removeObject: function(array, item) { + var index = utils.indexOf(array, item); + if (index !== -1) { array.splice(index, 1); } + }, + + replace: function(array, idx, amt, objects) { + if (array.replace) { + return array.replace(idx, amt, objects); + } else { + var args = Array.prototype.concat.apply([idx, amt], objects); + return array.splice.apply(array, args); + } + }, + + intersection: function(array1, array2) { + var intersection = []; + + array1.forEach(function(element) { + if (array2.indexOf(element) >= 0) { + intersection.push(element); + } + }); + + return intersection; + } +};
true
Other
emberjs
ember.js
f3789b7acdd9c025c33b0519304036ebc11769ef.json
Add intersection to enumerable utils
packages/ember-metal/tests/enumerable_utils_test.js
@@ -0,0 +1,9 @@ +module('Ember.EnumerableUtils.intersection'); + +test('returns an array of objects that appear in both enumerables', function() { + var a = [1,2,3], b = [2,3,4], result; + + result = Ember.EnumerableUtils.intersection(a, b); + + deepEqual(result, [2,3]); +});
true
Other
emberjs
ember.js
14d3f7920141600030c60d921c84f5385a28148b.json
Fix issue with Metamorph replace Scenario: Two nested {{if}}. Outer true, inner false. Step 1: Set inner to true. Step 2: Set outer to false in same runloop. Result: Children of the inner conditional are created without being destroyed. Expected: Children should not be created at all.
packages/ember-handlebars/lib/views/metamorph_view.js
@@ -36,7 +36,7 @@ var DOMManager = { view.transitionTo('preRender'); Ember.run.schedule('render', this, function() { - if (get(view, 'isDestroyed')) { return; } + if (view.isDestroying) { return; } view.clearRenderedChildren(); var buffer = view.renderToBuffer();
true
Other
emberjs
ember.js
14d3f7920141600030c60d921c84f5385a28148b.json
Fix issue with Metamorph replace Scenario: Two nested {{if}}. Outer true, inner false. Step 1: Set inner to true. Step 2: Set outer to false in same runloop. Result: Children of the inner conditional are created without being destroyed. Expected: Children should not be created at all.
packages/ember-handlebars/tests/handlebars_test.js
@@ -664,6 +664,32 @@ test("should update the block when object passed to #if helper changes and an in }); }); +test("edge case: child conditional should not render children if parent conditional becomes false", function() { + var childCreated = false; + + view = Ember.View.create({ + cond1: true, + cond2: false, + viewClass: Ember.View.extend({ + init: function() { + this._super(); + childCreated = true; + } + }), + template: Ember.Handlebars.compile('{{#if view.cond1}}{{#if view.cond2}}{{#view view.viewClass}}test{{/view}}{{/if}}{{/if}}') + }); + + appendView(); + + Ember.run(function() { + // The order of these sets is important for the test + view.set('cond2', true); + view.set('cond1', false); + }); + + ok(!childCreated, 'child should not be created'); +}); + // test("Should insert a localized string if the {{loc}} helper is used", function() { // Ember.stringsFor('en', { // 'Brazil': 'Brasilia'
true
Other
emberjs
ember.js
01e7f281a01f11c775f73072db55cf472df14391.json
Update documentation for logging transitions
lib/ember.js
@@ -24263,9 +24263,7 @@ var get = Ember.get, set = Ember.set, ```javascript window.App = Ember.Application.create({ - ready: function() { - this.set('router.enableLogging', true); - } + LOG_TRANSITIONS: true }); To begin routing, you must have at a minimum a top-level controller and view.
false
Other
emberjs
ember.js
42290bd66c38ce78122b66789eb3c898cd532dc8.json
Remove typos in code example
lib/ember.js
@@ -8195,7 +8195,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot arr.indexOf("a", -1); // 4 arr.indexOf("b", 3); // -1 arr.indexOf("a", 100); // -1 - ```javascript + ``` @method indexOf @param {Object} object the item to search for @@ -8840,7 +8840,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, var colors = ["red", "green", "blue"]; colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"] colors.insertAt(5, "orange"); // Error: Index out of range - ```javascript + ``` @method insertAt @param {Number} idx index of insert the object at.
true
Other
emberjs
ember.js
42290bd66c38ce78122b66789eb3c898cd532dc8.json
Remove typos in code example
packages/ember-old-router/lib/router.js
@@ -346,7 +346,7 @@ var merge = function(original, hash) { }) }); App.initialize(); - ```javascript + ``` And application code:
true
Other
emberjs
ember.js
42290bd66c38ce78122b66789eb3c898cd532dc8.json
Remove typos in code example
packages/ember-runtime/lib/mixins/array.js
@@ -180,7 +180,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot arr.indexOf("a", -1); // 4 arr.indexOf("b", 3); // -1 arr.indexOf("a", 100); // -1 - ```javascript + ``` @method indexOf @param {Object} object the item to search for
true
Other
emberjs
ember.js
42290bd66c38ce78122b66789eb3c898cd532dc8.json
Remove typos in code example
packages/ember-runtime/lib/mixins/mutable_array.js
@@ -83,7 +83,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, var colors = ["red", "green", "blue"]; colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"] colors.insertAt(5, "orange"); // Error: Index out of range - ```javascript + ``` @method insertAt @param {Number} idx index of insert the object at.
true
Other
emberjs
ember.js
3c3e77a72ff52b8ee3aaef9af145ddae8685cd16.json
Remove typos in code example
lib/ember.js
@@ -6373,7 +6373,7 @@ Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.i Ember.compare('hello', 'hello'); // 0 Ember.compare('abc', 'dfg'); // -1 Ember.compare(2, 1); // 1 - ```javascript + ``` @method compare @for Ember
true
Other
emberjs
ember.js
3c3e77a72ff52b8ee3aaef9af145ddae8685cd16.json
Remove typos in code example
packages/ember-runtime/lib/core.js
@@ -148,7 +148,7 @@ Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.i Ember.compare('hello', 'hello'); // 0 Ember.compare('abc', 'dfg'); // -1 Ember.compare(2, 1); // 1 - ```javascript + ``` @method compare @for Ember
true
Other
emberjs
ember.js
e0f7c70256a696538fd1f91b2d70025134a6551b.json
Use getURL() in HistoryLocation When trying to subclass HistoryLocation, it's hard to override certain methods, because they don't use public API of this class for getting URL. This patch changes all calls to location.pathname into getURL() calls.
packages/ember-routing/lib/location/history_location.js
@@ -29,7 +29,7 @@ Ember.HistoryLocation = Ember.Object.extend({ @method initState */ initState: function() { - this.replaceState(get(this, 'location').pathname); + this.replaceState(this.formatURL(this.getURL())); set(this, 'history', window.history); },
false
Other
emberjs
ember.js
8bd4aa3358616b3ff19b5a93da7e4c3f850831ca.json
Add documentation stub for Ember.Router Adding /** @scope Ember.Router.prototype */ makes YUIdoc print out the entire router definition, without any error message. It doesn't actually blow up, it just prints source. It's strange. The method listing don't seem right yet -- it contains methods like Ember.Route#controllerFor. But it's a start.
packages/ember-routing/lib/system/router.js
@@ -25,6 +25,14 @@ function setupLocation(router) { } } +/** + The `Ember.Router` class manages the application state and URLs. Refer to + the [routing guide](http://emberjs.com/guides/routing/) for documentation. + + @class Router + @namespace Ember + @extends Ember.Object +*/ Ember.Router = Ember.Object.extend({ location: 'hash',
false
Other
emberjs
ember.js
7c796e45649195ab88de86bcf3d503aed636e689.json
Skip container tests when testing build
Rakefile
@@ -87,14 +87,16 @@ task :test, [:suite] => :dist do |t, args| :standard => packages.map{|p| "package=#{p}" } + ["package=all&jquery=1.7.2&nojshint=true", "package=all&extendprototypes=true&nojshint=true", - "package=all&dist=build&nojshint=true"], + # container isn't publicly available in the built version + "package=all&skipPackage=container&dist=build&nojshint=true"], :all => packages.map{|p| "package=#{p}" } + ["package=all&jquery=1.7.2&nojshint=true", "package=all&jquery=1.8.3&nojshint=true", "package=all&jquery=git&nojshint=true", "package=all&extendprototypes=true&nojshint=true", "package=all&extendprototypes=true&jquery=git&nojshint=true", - "package=all&dist=build&nojshint=true"] + # container isn't publicly available in the built version + "package=all&skipPackage=container&dist=build&nojshint=true"] } packages.each do |package|
false
Other
emberjs
ember.js
14ec9b2219602d889f27c622a6bdc16c8fbc3986.json
Fix global leaks between tests
packages/ember-metal/tests/accessors/getPath_test.js
@@ -11,23 +11,23 @@ var obj, moduleOpts = { }; - Foo = { + window.Foo = { bar: { baz: { biff: 'FooBiff' } } }; - $foo = { + window.$foo = { bar: { baz: { biff: '$FOOBIFF' } } }; }, teardown: function() { - obj = null; - Foo = null; - $foo = null; + obj = undefined; + window.Foo = undefined; + window.$foo = undefined; } };
true
Other
emberjs
ember.js
14ec9b2219602d889f27c622a6bdc16c8fbc3986.json
Fix global leaks between tests
packages/ember-metal/tests/accessors/normalizeTuple_test.js
@@ -10,22 +10,23 @@ var obj, moduleOpts = { } }; - Foo = { + window.Foo = { bar: { baz: {} } }; - $foo = { + window.$foo = { bar: { baz: {} } }; }, teardown: function() { - obj = null; - Foo = null; + obj = undefined; + window.Foo = undefined; + window.$foo = undefined; } };
true
Other
emberjs
ember.js
cd23742826d041dbb55e763879fab6570882de43.json
Run container tests
Rakefile
@@ -83,7 +83,7 @@ task :test, [:suite] => :dist do |t, args| :default => packages.map{|p| "package=#{p}" }, :built => [ "package=all&dist=build" ], :runtime => [ "package=ember-metal,ember-runtime" ], - :views => [ "package=ember-views,ember-handlebars" ], + :views => [ "package=container,ember-views,ember-handlebars" ], :standard => packages.map{|p| "package=#{p}" } + ["package=all&jquery=1.7.2&nojshint=true", "package=all&extendprototypes=true&nojshint=true",
true
Other
emberjs
ember.js
cd23742826d041dbb55e763879fab6570882de43.json
Run container tests
tests/index.html
@@ -167,11 +167,12 @@ <h2 id="qunit-userAgent"></h2> if (packages[0] === 'all') { packages = [ - 'ember-handlebars', + 'container', 'ember-metal', 'ember-runtime', 'ember-states', 'ember-views', + 'ember-handlebars', 'ember-routing', 'ember-application', 'ember'
true
Other
emberjs
ember.js
b4189a5316b490e6523d0fa49a02f55bf9c91de0.json
Fix default index for Router#replaceWith
packages/ember-routing/lib/system/router.js
@@ -73,24 +73,14 @@ Ember.Router = Ember.Object.extend({ this.notifyPropertyChange('url'); }, - transitionTo: function(passedName) { - var args = [].slice.call(arguments), name; - - if (!this.router.hasRoute(passedName)) { - name = args[0] = passedName + '.index'; - } else { - name = passedName; - } - - Ember.assert("The route " + passedName + " was not found", this.router.hasRoute(name)); - - this.router.transitionTo.apply(this.router, args); - this.notifyPropertyChange('url'); + transitionTo: function(name) { + var args = [].slice.call(arguments); + doTransition(this, 'transitionTo', args); }, replaceWith: function() { - this.router.replaceWith.apply(this.router, arguments); - this.notifyPropertyChange('url'); + var args = [].slice.call(arguments); + doTransition(this, 'replaceWith', args); }, generate: function() { @@ -225,6 +215,21 @@ function setupRouter(emberRouter, router, location) { }; } +function doTransition(router, method, args) { + var passedName = args[0], name; + + if (!router.router.hasRoute(args[0])) { + name = args[0] = passedName + '.index'; + } else { + name = passedName; + } + + Ember.assert("The route " + passedName + " was not found", router.router.hasRoute(name)); + + router.router[method].apply(router.router, args); + router.notifyPropertyChange('url'); +} + Ember.Router.reopenClass({ map: function(callback) { var router = this.router = new Router();
false
Other
emberjs
ember.js
3f84548699fdf631b02be61d57456f67d3e45468.json
Update license year
LICENSE
@@ -1,4 +1,4 @@ -Copyright (c) 2012 Yehuda Katz, Tom Dale, Charles Jolley and Ember.js contributors +Copyright (c) 2013 Yehuda Katz, Tom Dale, Charles Jolley and Ember.js contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
true
Other
emberjs
ember.js
3f84548699fdf631b02be61d57456f67d3e45468.json
Update license year
generators/license.js
@@ -1,6 +1,6 @@ // ========================================================================== // Project: Ember - JavaScript Application Framework -// Copyright: ©2011-2012 Tilde Inc. and contributors +// Copyright: ©2011-2013 Tilde Inc. and contributors // Portions ©2006-2011 Strobe Inc. // Portions ©2008-2011 Apple Inc. All rights reserved. // License: Licensed under MIT license
true
Other
emberjs
ember.js
7aa2e11fbda64d3112bf69cc9e2382ad53f41f5f.json
Update router.js - Fixes #1800
packages/ember-routing/lib/vendor/router.js
@@ -159,13 +159,13 @@ define("router", Used internally by `generate` and `transitionTo`. */ - _paramsForHandler: function(handlerName, objects, callback) { + _paramsForHandler: function(handlerName, objects, doUpdate) { var handlers = this.recognizer.handlersFor(handlerName), params = {}, toSetup = [], startIdx = handlers.length, objectsToMatch = objects.length, - object, handlerObj, handler, names, i, len; + object, objectChanged, handlerObj, handler, names, i, len; // Find out which handler to start matching at for (i=handlers.length-1; i>=0 && objectsToMatch>0; i--) { @@ -184,25 +184,42 @@ define("router", handlerObj = handlers[i]; handler = this.getHandler(handlerObj.handler); names = handlerObj.names; + objectChanged = false; + // If it's a dynamic segment if (names.length) { - // Don't use objects if we haven't gotten to the match point yet - if (i >= startIdx && objects.length) { object = objects.shift(); } - else { object = handler.context; } + // If we have objects, use them + if (i >= startIdx) { + object = objects.shift(); + objectChanged = true; + // Otherwise use existing context + } else { + object = handler.context; + } + // Serialize to generate params if (handler.serialize) { merge(params, handler.serialize(object, names)); } - } else if (callback) { - object = callback(handler); - } else { - object = undefined; + // If it's not a dynamic segment and we're updating + } else if (doUpdate) { + // If we've passed the match point we need to deserialize again + // or if we never had a context + if (i > startIdx || !handler.hasOwnProperty('context')) { + if (handler.deserialize) { + object = handler.deserialize({}); + objectChanged = true; + } + // Otherwise use existing context + } else { + object = handler.context; + } } - // Make sure that we update the context here so it's available to // subsequent deserialize calls - if (handler.context !== object) { + if (doUpdate && objectChanged) { + // TODO: It's a bit awkward to set the context twice, see if we can DRY things up setContext(handler, object); } @@ -322,12 +339,7 @@ define("router", @private */ function doTransition(router, name, method, args) { - var output = router._paramsForHandler(name, args, function(handler) { - if (handler.hasOwnProperty('context')) { return handler.context; } - if (handler.deserialize) { return handler.deserialize({}); } - return null; - }); - + var output = router._paramsForHandler(name, args, true); var params = output.params, toSetup = output.toSetup; var url = router.recognizer.generate(name, params); @@ -376,6 +388,10 @@ define("router", } function proceed(value) { + if (handler.context !== object) { + setContext(handler, object); + } + var updatedObjects = objects.concat([{ context: value, handler: result.handler,
false
Other
emberjs
ember.js
6e6668a7acd93ccea5ccc7d87fe22414effa42c0.json
Add a test for this.render('template') It should pull in the associated controller.
packages/ember/tests/routing/basic_test.js
@@ -122,6 +122,30 @@ test("The Homepage with explicit template name in renderTemplate", function() { equal(Ember.$('h3:contains(Megatroll)', '#qunit-fixture').length, 1, "The homepage template was rendered"); }); +test("An alternate template will pull in an alternate controller", function() { + Router.map(function() { + this.route("home", { path: "/" }); + }); + + App.HomeRoute = Ember.Route.extend({ + renderTemplate: function() { + this.render('homepage'); + } + }); + + App.HomepageController = Ember.Controller.extend({ + home: "Comes from homepage" + }); + + bootApplication(); + + Ember.run(function() { + router.handleURL("/"); + }); + + equal(Ember.$('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, "The homepage template was rendered"); +}); + test("The Homepage with explicit template name in renderTemplate and controller", function() { Router.map(function() { this.route("home", { path: "/" });
false
Other
emberjs
ember.js
ec58bba6dfbacc4c2426bbf75c63435b48ae2aa0.json
Update version replace in release scripts
Rakefile
@@ -201,7 +201,7 @@ namespace :release do # Bump ember-metal/core version contents = File.read("packages/ember-metal/lib/core.js") - current_version = contents.match(/@version ([\w\.]+)/) && $1 + current_version = contents.match(/@version ([\w\.-]+)/) && $1 contents.gsub!(current_version, EMBER_VERSION); File.open("packages/ember-metal/lib/core.js", "w") do |file| @@ -433,10 +433,10 @@ namespace :release do about = File.read("tmp/website/source/about.html.erb") min_gz = Zlib::Deflate.deflate(File.read("dist/ember.min.js")).bytes.count / 1024 - about.gsub! %r{https://raw\.github\.com/emberjs/ember\.js/release-builds/ember-\d(?:\.(?:(?:\d+)|pre))*?(\.min)?\.js}, + about.gsub! %r{https://raw\.github\.com/emberjs/ember\.js/release-builds/ember-\d(?:[\.-](?:(?:\d+)|pre))*?(\.min)?\.js}, %{https://raw.github.com/emberjs/ember.js/release-builds/ember-#{EMBER_VERSION}\\1.js} - about.gsub!(/Ember \d(\.((\d+)|pre))*/, "Ember #{EMBER_VERSION}") + about.gsub!(/Ember \d([\.-]((\d+)|pre))*/, "Ember #{EMBER_VERSION}") about.gsub!(/\d+k min\+gzip/, "#{min_gz}k min+gzip")
false
Other
emberjs
ember.js
b54825d70ffc104291d6feec8ce28d18ec130a15.json
Exclude vendor directories from docs
docs/yuidoc.json
@@ -15,6 +15,7 @@ "../packages/ember-routing/lib", "../packages/ember-application/lib" ], + "exclude": "vendor", "outdir": "./build" } }
false
Other
emberjs
ember.js
f1d54fb74899fbae1452c1f013dbc69050346d37.json
Support jQuery 1.9.0
README.md
@@ -127,7 +127,7 @@ To run multiple packages, you can separate them with commas. You can run all the <http://localhost:9292/tests/index.html?package=all> -You can also pass `jquery=VERSION` in the test URL to test different versions of jQuery. Default is 1.7.2. +You can also pass `jquery=VERSION` in the test URL to test different versions of jQuery. Default is 1.9.0. ## From the CLI
true
Other
emberjs
ember.js
f1d54fb74899fbae1452c1f013dbc69050346d37.json
Support jQuery 1.9.0
Rakefile
@@ -75,6 +75,7 @@ task :test, [:suite] => :dist do |t, args| "package=all&dist=build&nojshint=true"], :all => packages.map{|p| "package=#{p}" } + ["package=all&jquery=1.7.2&nojshint=true", + "package=all&jquery=1.8.3&nojshint=true", "package=all&jquery=git&nojshint=true", "package=all&extendprototypes=true&nojshint=true", "package=all&extendprototypes=true&jquery=git&nojshint=true",
true
Other
emberjs
ember.js
f1d54fb74899fbae1452c1f013dbc69050346d37.json
Support jQuery 1.9.0
packages/ember-views/lib/core.js
@@ -4,7 +4,7 @@ */ var jQuery = Ember.imports.jQuery; -Ember.assert("Ember Views require jQuery 1.7 (>= 1.7.2) or 1.8", jQuery && (jQuery().jquery.match(/^1\.(7(?!$)(?!\.[01])|8)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY)); +Ember.assert("Ember Views require jQuery 1.7 (>= 1.7.2), 1.8 or 1.9", jQuery && (jQuery().jquery.match(/^1\.(7(?!$)(?!\.[01])|8|9)(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY)); /** Alias for jQuery
true
Other
emberjs
ember.js
f1d54fb74899fbae1452c1f013dbc69050346d37.json
Support jQuery 1.9.0
tests/index.html
@@ -96,7 +96,7 @@ <h2 id="qunit-userAgent"></h2> <script> // Load custom version of jQuery if possible (assign to window so IE8 can use in later blocks) - var jQueryVersion = QUnit.urlParams.jquery || "1.8.2"; + var jQueryVersion = QUnit.urlParams.jquery || "1.9.0"; if (jQueryVersion !== 'none') { document.write('<script src="http://code.jquery.com/jquery-'+jQueryVersion+'.js"><\/script>'); }
true
Other
emberjs
ember.js
c0cbf374940507c57af748fbc9015ef04ab70363.json
Add helpful assert for non-route controllers
packages/ember-routing/lib/system/route.js
@@ -248,6 +248,9 @@ Ember.Route = Ember.Object.extend({ if (!controller) { model = model || this.modelFor(name); + + Ember.assert("You are trying to look up a controller that you did not define, and for which Ember does not know the model.\n\nThis is not a controller for a route, so you must explicitly define the controller ("+this.router.namespace.toString() + "." + Ember.String.capitalize(Ember.String.camelize(name))+"Controller) or pass a model as the second parameter to `controllerFor`, so that Ember knows which type of controller to create for you.", model || this.container.lookup('route:' + name)); + controller = Ember.generateController(container, name, model); } @@ -265,7 +268,8 @@ Ember.Route = Ember.Object.extend({ @return {Object} the model object */ modelFor: function(name) { - return this.container.lookup('route:' + name).currentModel; + var route = this.container.lookup('route:' + name); + return route && route.currentModel; }, /**
true
Other
emberjs
ember.js
c0cbf374940507c57af748fbc9015ef04ab70363.json
Add helpful assert for non-route controllers
packages/ember/tests/routing/basic_test.js
@@ -1227,3 +1227,17 @@ test("Parent route context change", function() { equal(editCount, 2, 'set up the edit route twice without failure'); deepEqual(editedPostIds, ['1', '2'], 'modelFor posts.post returns the right context'); }); + +test("Calling controllerFor for a non-route controller returns a controller", function() { + var controller; + + App.ApplicationRoute = Ember.Route.extend({ + setupController: function() { + controller = this.controllerFor('nonDefinedRoute', {}); + } + }); + + bootApplication(); + + ok(controller instanceof Ember.ObjectController, "controller was able to be retrieved"); +});
true
Other
emberjs
ember.js
a1aa67ab3db06cb2018f482a721324f38f240529.json
Fix duplicate test name
packages/ember/tests/routing/basic_test.js
@@ -122,7 +122,7 @@ test("The Homepage with explicit template name in renderTemplate", function() { equal(Ember.$('h3:contains(Megatroll)', '#qunit-fixture').length, 1, "The homepage template was rendered"); }); -test("The Homepage with explicit template name in renderTemplate", function() { +test("The Homepage with explicit template name in renderTemplate and controller", function() { Router.map(function(match) { this.route("home", { path: "/" }); });
false
Other
emberjs
ember.js
a60bd5fd92a7c3b4a5c407dbab52ae8d3030089b.json
Fix Route#render with slash notation
packages/ember-routing/lib/system/route.js
@@ -335,7 +335,7 @@ Ember.Route = Ember.Object.extend({ name = this.templateName; } - name = name || this.templateName; + name = name ? name.replace(/\//g, '.') : this.templateName; var container = this.container, view = container.lookup('view:' + name),
true
Other
emberjs
ember.js
a60bd5fd92a7c3b4a5c407dbab52ae8d3030089b.json
Fix Route#render with slash notation
packages/ember/tests/routing/basic_test.js
@@ -146,6 +146,32 @@ test("The Homepage with explicit template name in renderTemplate", function() { equal(Ember.$('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, "The homepage template was rendered"); }); +test("Renders correct view with slash notation", function() { + Ember.TEMPLATES['home/page'] = compile("<p>{{view.name}}</p>"); + + Router.map(function(match) { + this.route("home", { path: "/" }); + }); + + App.HomeRoute = Ember.Route.extend({ + renderTemplate: function() { + this.render('home/page'); + } + }); + + App.HomePageView = Ember.View.extend({ + name: "Home/Page" + }); + + bootApplication(); + + Ember.run(function() { + router.handleURL("/"); + }); + + equal(Ember.$('p:contains(Home/Page)', '#qunit-fixture').length, 1, "The homepage template was rendered"); +}); + test('render does not replace templateName if user provided', function() { Router.map(function(match) { this.route("home", { path: "/" });
true
Other
emberjs
ember.js
1cb786d770b754cb591284785d7250abc10c3193.json
Fix tests so that controllers are not routes
packages/ember/tests/routing/basic_test.js
@@ -58,7 +58,7 @@ test("The Homepage", function() { var currentPath; - App.ApplicationController = Ember.Route.extend({ + App.ApplicationController = Ember.Controller.extend({ currentPathDidChange: Ember.observer(function() { currentPath = get(this, 'currentPath'); }, 'currentPath') @@ -127,7 +127,7 @@ test("The Homepage with explicit template name in renderTemplate", function() { this.route("home", { path: "/" }); }); - App.HomeController = Ember.Route.extend({ + App.HomeController = Ember.Controller.extend({ home: "YES I AM HOME" }); @@ -158,7 +158,7 @@ test('render does not replace templateName if user provided', function() { App.HomeView = Ember.View.extend({ templateName: 'the_real_home_template' }); - App.HomeController = Ember.Route.extend(); + App.HomeController = Ember.Controller.extend(); App.HomeRoute = Ember.Route.extend(); bootApplication(); @@ -539,7 +539,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { var currentPath; - App.ApplicationController = Ember.Route.extend({ + App.ApplicationController = Ember.Controller.extend({ currentPathDidChange: Ember.observer(function() { currentPath = get(this, 'currentPath'); }, 'currentPath')
false
Other
emberjs
ember.js
8604952ded96faa5ab172a60bc8279f4c3245d41.json
add container#reset useful in tests
packages/container/lib/main.js
@@ -151,6 +151,13 @@ define("container", delete this.parent; this.isDestroyed = true; + }, + + reset: function() { + for (var i=0, l=this.children.length; i<l; i++) { + resetCache(this.children[i]); + } + resetCache(this); } }; @@ -231,5 +238,13 @@ define("container", }); } + function resetCache(container) { + container.cache.eachLocal(function(key, value) { + if (option(container, key, 'instantiate') === false) { return; } + value.destroy(); + }); + container.cache.dict = {}; + } + return Container; });
false
Other
emberjs
ember.js
ddb09515a0abf34d35c432b4a178d708ca5f470a.json
Fix failing router tests using old API
packages/ember/tests/routing/basic_test.js
@@ -148,7 +148,7 @@ test("The Homepage with explicit template name in renderTemplate", function() { test('render does not replace templateName if user provided', function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); Ember.TEMPLATES.the_real_home_template = Ember.Handlebars.compile( @@ -792,9 +792,9 @@ test('navigating away triggers a url property change', function() { var urlPropertyChangeCount = 0; Router.map(function(match) { - match("/").to("root"); - match("/foo").to("foo"); - match("/bar").to("bar"); + this.route('root', { path: '/' }); + this.route('foo', { path: '/foo' }); + this.route('bar', { path: '/bar' }); }); bootApplication();
false
Other
emberjs
ember.js
e4af09edd357cdccfddfa684247bc43a6eaae0fe.json
Change the API to this.resource/this.route This will hopefully be the last API change. Website docs forthcoming.
packages/ember-routing/lib/system.js
@@ -1,3 +1,4 @@ +require('ember-routing/system/dsl'); require('ember-routing/system/controller_for'); require('ember-routing/system/router'); require('ember-routing/system/route');
true
Other
emberjs
ember.js
e4af09edd357cdccfddfa684247bc43a6eaae0fe.json
Change the API to this.resource/this.route This will hopefully be the last API change. Website docs forthcoming.
packages/ember-routing/lib/system/dsl.js
@@ -0,0 +1,74 @@ +function DSL(name) { + this.parent = name; + this.matches = []; +} + +DSL.prototype = { + resource: function(name, options, callback) { + if (arguments.length === 2 && typeof options === 'function') { + callback = options; + options = {}; + } + + if (arguments.length === 1) { + options = {}; + } + + if (typeof options.path !== 'string') { + options.path = "/" + name; + } + + if (callback) { + var dsl = new DSL(name); + callback.call(dsl); + this.push(options.path, name, dsl.generate()); + } else { + this.push(options.path, name); + } + }, + + push: function(url, name, callback) { + if (url === "" || url === "/") { this.explicitIndex = true; } + + this.matches.push([url, name, callback]); + }, + + route: function(name, options) { + Ember.assert("You must use `this.resource` to nest", typeof options !== 'function'); + + options = options || {}; + + if (typeof options.path !== 'string') { + options.path = "/" + name; + } + + if (this.parent && this.parent !== 'application') { + name = this.parent + "." + name; + } + + this.push(options.path, name); + }, + + generate: function() { + var dslMatches = this.matches; + + if (!this.explicitIndex) { + this.route("index", { path: "/" }); + } + + return function(match) { + for (var i=0, l=dslMatches.length; i<l; i++) { + var dslMatch = dslMatches[i]; + match(dslMatch[0]).to(dslMatch[1], dslMatch[2]); + } + }; + } +}; + +DSL.map = function(callback) { + var dsl = new DSL(); + callback.call(dsl); + return dsl; +}; + +Ember.RouterDSL = DSL;
true
Other
emberjs
ember.js
e4af09edd357cdccfddfa684247bc43a6eaae0fe.json
Change the API to this.resource/this.route This will hopefully be the last API change. Website docs forthcoming.
packages/ember-routing/lib/system/router.js
@@ -3,6 +3,8 @@ var get = Ember.get, set = Ember.set, classify = Ember.String.classify; var DefaultView = Ember.View.extend(Ember._Metamorph); +require("ember-routing/system/dsl"); + function setupLocation(router) { var location = get(router, 'location'), rootURL = get(router, 'rootURL'); @@ -28,7 +30,7 @@ Ember.Router = Ember.Object.extend({ }, startRouting: function() { - this.router = this.router || this.constructor.map(); + this.router = this.router || this.constructor.map(Ember.K); var router = this.router, location = get(this, 'location'), @@ -215,36 +217,17 @@ function setupRouter(emberRouter, router, location) { }; } -function setupRouterDelegate(router, namespace) { - router.delegate = { - willAddRoute: function(context, handler) { - if (!context) { return handler; } - - if (context === 'application' || context === undefined) { - return handler; - } else if (handler.indexOf('.') === -1) { - context = context.split('.').slice(-1)[0]; - return context + '.' + handler; - } else { - return handler; - } - }, - - contextEntered: function(target, match) { - match('/').to('index'); - } - }; -} - -var emptyMatcherCallback = function(match) { }; - Ember.Router.reopenClass({ map: function(callback) { var router = this.router = new Router(); - setupRouterDelegate(router, this.namespace); - router.map(function(match) { - match("/").to("application", callback || emptyMatcherCallback); + + var dsl = Ember.RouterDSL.map(function() { + this.resource('application', { path: "/" }, function() { + callback.call(this); + }); }); + + router.map(dsl.generate()); return router; } });
true
Other
emberjs
ember.js
e4af09edd357cdccfddfa684247bc43a6eaae0fe.json
Change the API to this.resource/this.route This will hopefully be the last API change. Website docs forthcoming.
packages/ember/tests/helpers/link_to_test.js
@@ -54,7 +54,7 @@ module("The {{linkTo}} helper", { test("The {{linkTo}} helper moves into the named route", function() { Router.map(function(match) { - match("/about").to("about"); + this.route("about"); }); bootApplication(); @@ -96,8 +96,8 @@ test("The {{linkTo}} helper supports URL replacement", function() { }) }); - Router.map(function(match) { - match("/about").to("about"); + Router.map(function() { + this.route("about"); }); bootApplication(); @@ -120,8 +120,8 @@ test("The {{linkTo}} helper supports URL replacement", function() { test("The {{linkTo}} helper supports a custom activeClass", function() { Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{#linkTo about id='about-link'}}About{{/linkTo}}{{#linkTo index id='self-link' activeClass='zomg-active'}}Self{{/linkTo}}"); - Router.map(function(match) { - match("/about").to("about"); + Router.map(function() { + this.route("about"); }); bootApplication(); @@ -136,9 +136,9 @@ test("The {{linkTo}} helper supports a custom activeClass", function() { }); test("The {{linkTo}} helper supports leaving off .index for nested routes", function() { - Router.map(function(match) { - match("/about").to("about", function(match) { - match("/item").to("item"); + Router.map(function() { + this.resource("about", function() { + this.route("item"); }); }); @@ -157,10 +157,11 @@ test("The {{linkTo}} helper supports leaving off .index for nested routes", func test("The {{linkTo}} helper supports custom, nested, currentWhen", function() { Router.map(function(match) { - match("/").to("index", function(match) { - match("/about").to("about"); + this.resource("index", { path: "/" }, function() { + this.route("about"); }); - match("/item").to("item"); + + this.route("item"); }); Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{outlet}}"); @@ -179,9 +180,9 @@ test("The {{linkTo}} helper defaults to bubbling", function() { Ember.TEMPLATES.about = Ember.Handlebars.compile("<button {{action 'hide'}}>{{#linkTo 'about.contact' id='about-contact'}}About{{/linkTo}}</button>{{outlet}}"); Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile("<h1 id='contact'>Contact</h1>"); - Router.map(function(match) { - match("/about").to("about", function(match) { - match("/contact").to("contact"); + Router.map(function() { + this.resource("about", function() { + this.route("contact"); }); }); @@ -214,9 +215,9 @@ test("The {{linkTo}} helper supports bubbles=false", function() { Ember.TEMPLATES.about = Ember.Handlebars.compile("<button {{action 'hide'}}>{{#linkTo 'about.contact' id='about-contact' bubbles=false}}About{{/linkTo}}</button>{{outlet}}"); Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile("<h1 id='contact'>Contact</h1>"); - Router.map(function(match) { - match("/about").to("about", function(match) { - match("/contact").to("contact"); + Router.map(function() { + this.resource("about", function() { + this.route("contact"); }); }); @@ -247,8 +248,8 @@ test("The {{linkTo}} helper supports bubbles=false", function() { test("The {{linkTo}} helper moves into the named route with context", function() { Router.map(function(match) { - match("/about").to("about"); - match("/item/:id").to("item"); + this.route("about"); + this.resource("item", { path: "/item/:id" }); }); Ember.TEMPLATES.about = Ember.Handlebars.compile("<h3>List</h3><ul>{{#each controller}}<li>{{#linkTo item this}}{{name}}{{/linkTo}}<li>{{/each}}</ul>{{#linkTo index id='home-link'}}Home{{/linkTo}}");
true
Other
emberjs
ember.js
e4af09edd357cdccfddfa684247bc43a6eaae0fe.json
Change the API to this.resource/this.route This will hopefully be the last API change. Website docs forthcoming.
packages/ember/tests/routing/basic_test.js
@@ -50,7 +50,7 @@ module("Basic Routing", { test("The Homepage", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeRoute = Ember.Route.extend({ @@ -76,8 +76,8 @@ test("The Homepage", function() { test("The Homepage register as activeView", function() { Router.map(function(match) { - match("/").to("home"); - match("/homepage").to("homepage"); + this.route("home", { path: "/" }); + this.route("homepage"); }); App.HomeRoute = Ember.Route.extend({ @@ -104,7 +104,7 @@ test("The Homepage register as activeView", function() { test("The Homepage with explicit template name in renderTemplate", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeRoute = Ember.Route.extend({ @@ -124,7 +124,7 @@ test("The Homepage with explicit template name in renderTemplate", function() { test("The Homepage with explicit template name in renderTemplate", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeController = Ember.Route.extend({ @@ -172,7 +172,7 @@ test('render does not replace templateName if user provided', function() { test("The Homepage with a `setupController` hook", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeRoute = Ember.Route.extend({ @@ -202,7 +202,7 @@ test("The Homepage with a `setupController` hook", function() { test("The Homepage with a `setupController` hook modifying other controllers", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeRoute = Ember.Route.extend({ @@ -232,7 +232,7 @@ test("The Homepage with a `setupController` hook modifying other controllers", f test("The Homepage getting its controller context via model", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); App.HomeRoute = Ember.Route.extend({ @@ -268,8 +268,8 @@ test("The Homepage getting its controller context via model", function() { test("The Specials Page getting its controller context by deserializing the params hash", function() { Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); App.SpecialRoute = Ember.Route.extend({ @@ -301,8 +301,8 @@ test("The Specials Page getting its controller context by deserializing the para test("The Specials Page defaults to looking models up via `find`", function() { Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); App.MenuItem = Ember.Object.extend(); @@ -337,8 +337,8 @@ test("The Special Page returning a promise puts the app into a loading state unt stop(); Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); var menuItem; @@ -391,8 +391,8 @@ test("The Special page returning an error puts the app into the failure state", stop(); Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); var menuItem; @@ -433,8 +433,8 @@ test("The Special page returning an error puts the app into a default failure st stop(); Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); var lastFailure; @@ -475,8 +475,8 @@ test("The Special page returning an error puts the app into a default failure st test("Moving from one page to another triggers the correct callbacks", function() { Router.map(function(match) { - match("/").to("home"); - match("/specials/:menu_item_id").to("special"); + this.route("home", { path: "/" }); + this.resource("special", { path: "/specials/:menu_item_id" }); }); var menuItem; @@ -532,8 +532,8 @@ test("Moving from one page to another triggers the correct callbacks", function( test("Nested callbacks are not exited when moving to siblings", function() { Router.map(function(match) { - match("/").to("root", function(match) { - match("/specials/:menu_item_id").to("special"); + this.resource("root", { path: "/" }, function(match) { + this.resource("special", { path: "/specials/:menu_item_id" }); }); }); @@ -581,7 +581,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { }); - App.RootSpecialRoute = Ember.Route.extend({ + App.SpecialRoute = Ember.Route.extend({ setupController: function(controller, model) { set(controller, 'content', model); } @@ -591,7 +591,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { "<h3>Home</h3>" ); - Ember.TEMPLATES['root/special'] = Ember.Handlebars.compile( + Ember.TEMPLATES.special = Ember.Handlebars.compile( "<p>{{content.id}}</p>" ); @@ -616,7 +616,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { router = container.lookup('router:main'); Ember.run(function() { - router.transitionTo('root.special', App.MenuItem.create({ id: 1 })); + router.transitionTo('special', App.MenuItem.create({ id: 1 })); }); equal(rootSetup, 1, "The root setup was not triggered again"); equal(rootRender, 1, "The root render was not triggered again"); @@ -631,7 +631,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { asyncTest("Events are triggered on the controller if a matching action name is implemented", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); var model = { name: "Tom Dale" }; @@ -678,7 +678,7 @@ asyncTest("Events are triggered on the controller if a matching action name is i asyncTest("Events are triggered on the current state", function() { Router.map(function(match) { - match("/").to("home"); + this.route("home", { path: "/" }); }); var model = { name: "Tom Dale" }; @@ -721,7 +721,8 @@ asyncTest("Events are triggered on the current state", function() { asyncTest("Events are triggered on the current state when routes are nested", function() { Router.map(function(match) { - match("/").to("root", function(match) { + this.resource("root", { path: "/" }, function() { + this.route("index", { path: "/" }); }); }); @@ -758,9 +759,9 @@ asyncTest("Events are triggered on the current state when routes are nested", fu test("transitioning multiple times in a single run loop only sets the URL once", function() { Router.map(function(match) { - match("/").to("root"); - match("/foo").to("foo"); - match("/bar").to("bar"); + this.route("root", { path: "/" }); + this.route("foo"); + this.route("bar"); }); bootApplication(); @@ -842,8 +843,8 @@ test("using replaceWith calls location.replaceURL if available", function() { }); Router.map(function(match) { - match("/").to("root"); - match("/foo").to("foo"); + this.route("root", { path: "/" }); + this.route("foo"); }); bootApplication(); @@ -877,8 +878,8 @@ test("using replaceWith calls setURL if location.replaceURL is not defined", fun }); Router.map(function(match) { - match("/").to("root"); - match("/foo").to("foo"); + this.route("root", { path: "/" }); + this.route("foo"); }); bootApplication(); @@ -901,9 +902,8 @@ test("It is possible to get the model from a parent route", function() { expect(3); Router.map(function(match) { - match("/").to("index"); - match("/posts/:post_id").to("post", function(match) { - match("/comments").to("comments"); + this.resource("post", { path: "/posts/:post_id" }, function() { + this.resource("comments"); }); }); @@ -921,7 +921,7 @@ test("It is possible to get the model from a parent route", function() { } }); - App.PostCommentsRoute = Ember.Route.extend({ + App.CommentsRoute = Ember.Route.extend({ model: function() { equal(this.modelFor('post'), currentPost); } @@ -947,8 +947,8 @@ test("It is possible to get the model from a parent route", function() { test("A redirection hook is provided", function() { Router.map(function(match) { - match("/").to("choose"); - match("/home").to("home"); + this.route("choose", { path: "/" }); + this.route("home"); }); var chooseFollowed = 0, destination; @@ -978,38 +978,38 @@ test("Generated names can be customized when providing routes with dot notation" Ember.TEMPLATES.index = compile("<div>Index</div>"); Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>"); - Ember.TEMPLATES.top = compile("<div class='middle'>{{outlet}}</div>"); - Ember.TEMPLATES['foo/bar'] = compile("<div class='bottom'>{{outlet}}</div>"); - Ember.TEMPLATES['baz/bang'] = compile("<p>{{name}}Bottom!</p>"); + Ember.TEMPLATES.foo = compile("<div class='middle'>{{outlet}}</div>"); + Ember.TEMPLATES.bar = compile("<div class='bottom'>{{outlet}}</div>"); + Ember.TEMPLATES['bar/baz'] = compile("<p>{{name}}Bottom!</p>"); Router.map(function(match) { - match("/top").to("top", function(match) { - match("/middle").to("foo.bar", function(match) { - match("/bottom").to("baz.bang"); + this.resource("foo", { path: "/top" }, function() { + this.resource("bar", { path: "/middle" }, function() { + this.route("baz", { path: "/bottom" }); }); }); }); - App.FooBarRoute = Ember.Route.extend({ + App.FooRoute = Ember.Route.extend({ renderTemplate: function() { ok(true, "FooBarRoute was called"); return this._super.apply(this, arguments); } }); - App.BazBangRoute = Ember.Route.extend({ + App.BarBazRoute = Ember.Route.extend({ renderTemplate: function() { - ok(true, "BazBangRoute was called"); + ok(true, "BarBazRoute was called"); return this._super.apply(this, arguments); } }); - App.FooBarController = Ember.Controller.extend({ - name: "FooBar" + App.BarController = Ember.Controller.extend({ + name: "Bar" }); - App.BazBangController = Ember.Controller.extend({ - name: "BazBang" + App.BarBazController = Ember.Controller.extend({ + name: "BarBaz" }); bootApplication(); @@ -1018,20 +1018,20 @@ test("Generated names can be customized when providing routes with dot notation" router.handleURL("/top/middle/bottom"); }); - equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "BazBangBottom!", "The templates were rendered into their appropriate parents"); + equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "BarBazBottom!", "The templates were rendered into their appropriate parents"); }); test("Child routes render into their parent route's template by default", function() { Ember.TEMPLATES.index = compile("<div>Index</div>"); Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>"); Ember.TEMPLATES.top = compile("<div class='middle'>{{outlet}}</div>"); - Ember.TEMPLATES['top/middle'] = compile("<div class='bottom'>{{outlet}}</div>"); + Ember.TEMPLATES.middle = compile("<div class='bottom'>{{outlet}}</div>"); Ember.TEMPLATES['middle/bottom'] = compile("<p>Bottom!</p>"); Router.map(function(match) { - match("/top").to("top", function(match) { - match("/middle").to("middle", function(match) { - match("/bottom").to("bottom"); + this.resource("top", function() { + this.resource("middle", function() { + this.route("bottom"); }); }); }); @@ -1051,14 +1051,14 @@ test("Parent route context change", function() { Ember.TEMPLATES.application = compile("{{outlet}}"); Ember.TEMPLATES.posts = compile("{{outlet}}"); - Ember.TEMPLATES['posts/post'] = compile("{{outlet}}"); + Ember.TEMPLATES.post = compile("{{outlet}}"); Ember.TEMPLATES['post/index'] = compile("showing"); Ember.TEMPLATES['post/edit'] = compile("editing"); - Router.map(function(match) { - match("/posts").to("posts", function(match) { - match("/:postId").to('post', function(match) { - match("/edit").to('edit'); + Router.map(function() { + this.resource("posts", function() { + this.resource("post", { path: "/:postId" }, function() { + this.route("edit"); }); }); }); @@ -1071,7 +1071,7 @@ test("Parent route context change", function() { } }); - App.PostsPostRoute = Ember.Route.extend({ + App.PostRoute = Ember.Route.extend({ model: function(params) { return {id: params.postId}; },
true
Other
emberjs
ember.js
da4aa8531f337811c69e86300d81352fc1dab241.json
Add `action` support to Ember.TextField
packages/ember-handlebars/lib/controls/text_field.js
@@ -81,5 +81,29 @@ Ember.TextField = Ember.View.extend(Ember.TextSupport, @type String @default null */ - size: null + size: null, + + /** + The action to be sent when the user presses the return key. + + This is similar to the `{{action}}` helper, but is fired when + the user presses the return key when editing a text field, and sends + the value of the field as the context. + + @property action + @type String + @default null + */ + action: null, + + insertNewline: function() { + var controller = get(this, 'controller'), + action = get(this, 'action'); + + if (action) { + controller.send(action, get(this, 'value')); + } + + return false; + } });
true
Other
emberjs
ember.js
da4aa8531f337811c69e86300d81352fc1dab241.json
Add `action` support to Ember.TextField
packages/ember-handlebars/tests/controls/text_field_test.js
@@ -173,6 +173,29 @@ test("should call the cancel method when escape key is pressed", function() { ok(wasCalled, "invokes cancel method"); }); +test("should sent an action if one is defined when the return key is pressed", function() { + expect(2); + + var StubController = Ember.Object.extend({ + send: function(actionName, arg1) { + equal(actionName, 'didTriggerAction', "text field sent correct action name"); + equal(arg1, "textFieldValue", "text field sent its current value as first argument"); + } + }); + + textField.set('action', 'didTriggerAction'); + textField.set('value', "textFieldValue"); + textField.set('controller', StubController.create()); + + Ember.run(function() { textField.append(); }); + + var event = { + keyCode: 13 + }; + + textField.trigger('keyUp', event); +}); + // test("listens for focus and blur events", function() { // var focusCalled = 0; // var blurCalled = 0;
true
Other
emberjs
ember.js
d1116a1cef2c2e52c188b6f534c6b771a2c898d9.json
update Metamorph with latest amd distribution
packages/metamorph/lib/main.js
@@ -1,458 +1,458 @@ -// ========================================================================== -// Project: metamorph -// Copyright: ©2011 My Company Inc. All rights reserved. -// ========================================================================== - define("metamorph", [], function() { + "use strict"; + // ========================================================================== + // Project: metamorph + // Copyright: ©2011 My Company Inc. All rights reserved. + // ========================================================================== + + var K = function(){}, + guid = 0, + document = window.document, + + // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges + supportsRange = ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, + + // 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 &shy; + needsShy = (function(){ + var testEl = document.createElement('div'); + testEl.innerHTML = "<div></div>"; + testEl.firstChild.innerHTML = "<script></script>"; + return testEl.firstChild.innerHTML === ''; + })(), + + + // IE 8 (and likely earlier) likes to move whitespace preceeding + // a script tag to appear after it. This means that we can + // accidentally remove whitespace when updating a morph. + movesWhitespace = (function() { + var testEl = document.createElement('div'); + testEl.innerHTML = "Test: <script type='text/x-placeholder'></script>Value"; + return testEl.childNodes[0].nodeValue === 'Test:' && + testEl.childNodes[2].nodeValue === ' Value'; + })(); + + // Constructor that supports either Metamorph('foo') or new + // Metamorph('foo'); + // + // Takes a string of HTML as the argument. - var K = function(){}, - guid = 0, - document = window.document, - - // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges - supportsRange = ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, - - // 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 &shy; - needsShy = (function(){ - var testEl = document.createElement('div'); - testEl.innerHTML = "<div></div>"; - testEl.firstChild.innerHTML = "<script></script>"; - return testEl.firstChild.innerHTML === ''; - })(), - - - // IE 8 (and likely earlier) likes to move whitespace preceeding - // a script tag to appear after it. This means that we can - // accidentally remove whitespace when updating a morph. - movesWhitespace = (function() { - var testEl = document.createElement('div'); - testEl.innerHTML = "Test: <script type='text/x-placeholder'></script>Value"; - return testEl.childNodes[0].nodeValue === 'Test:' && - testEl.childNodes[2].nodeValue === ' Value'; - })(); - - // Constructor that supports either Metamorph('foo') or new - // Metamorph('foo'); - // - // Takes a string of HTML as the argument. - - var Metamorph = function(html) { - var self; - - if (this instanceof Metamorph) { - self = this; - } else { - self = new K(); - } + var Metamorph = function(html) { + var self; - self.innerHTML = html; - var myGuid = 'metamorph-'+(guid++); - self.start = myGuid + '-start'; - self.end = myGuid + '-end'; - - return self; - }; - - K.prototype = Metamorph.prototype; - - var rangeFor, htmlFunc, removeFunc, outerHTMLFunc, appendToFunc, afterFunc, prependFunc, startTagFunc, endTagFunc; - - outerHTMLFunc = function() { - return this.startTag() + this.innerHTML + this.endTag(); - }; - - startTagFunc = function() { - /* - * We replace chevron by its hex code in order to prevent escaping problems. - * Check this thread for more explaination: - * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript - */ - return "<script id='" + this.start + "' type='text/x-placeholder'>\x3C/script>"; - }; - - endTagFunc = function() { - /* - * We replace chevron by its hex code in order to prevent escaping problems. - * Check this thread for more explaination: - * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript - */ - return "<script id='" + this.end + "' type='text/x-placeholder'>\x3C/script>"; - }; - - // If we have the W3C range API, this process is relatively straight forward. - if (supportsRange) { - - // Get a range for the current morph. Optionally include the starting and - // ending placeholders. - rangeFor = function(morph, outerToo) { - var range = document.createRange(); - var before = document.getElementById(morph.start); - var after = document.getElementById(morph.end); - - if (outerToo) { - range.setStartBefore(before); - range.setEndAfter(after); + if (this instanceof Metamorph) { + self = this; } else { - range.setStartAfter(before); - range.setEndBefore(after); + self = new K(); } - return range; - }; - - htmlFunc = function(html, outerToo) { - // get a range for the current metamorph object - var range = rangeFor(this, outerToo); - - // delete the contents of the range, which will be the - // nodes between the starting and ending placeholder. - range.deleteContents(); + self.innerHTML = html; + var myGuid = 'metamorph-'+(guid++); + self.start = myGuid + '-start'; + self.end = myGuid + '-end'; - // create a new document fragment for the HTML - var fragment = range.createContextualFragment(html); - - // insert the fragment into the range - range.insertNode(fragment); + return self; }; - removeFunc = function() { - // get a range for the current metamorph object including - // the starting and ending placeholders. - var range = rangeFor(this, true); + K.prototype = Metamorph.prototype; - // delete the entire range. - range.deleteContents(); - }; + var rangeFor, htmlFunc, removeFunc, outerHTMLFunc, appendToFunc, afterFunc, prependFunc, startTagFunc, endTagFunc; - appendToFunc = function(node) { - var range = document.createRange(); - range.setStart(node); - range.collapse(false); - var frag = range.createContextualFragment(this.outerHTML()); - node.appendChild(frag); + outerHTMLFunc = function() { + return this.startTag() + this.innerHTML + this.endTag(); }; - afterFunc = function(html) { - var range = document.createRange(); - var after = document.getElementById(this.end); - - range.setStartAfter(after); - range.setEndAfter(after); + startTagFunc = function() { + /* + * We replace chevron by its hex code in order to prevent escaping problems. + * Check this thread for more explaination: + * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript + */ + return "<script id='" + this.start + "' type='text/x-placeholder'>\x3C/script>"; + }; - var fragment = range.createContextualFragment(html); - range.insertNode(fragment); + endTagFunc = function() { + /* + * We replace chevron by its hex code in order to prevent escaping problems. + * Check this thread for more explaination: + * http://stackoverflow.com/questions/8231048/why-use-x3c-instead-of-when-generating-html-from-javascript + */ + return "<script id='" + this.end + "' type='text/x-placeholder'>\x3C/script>"; }; - prependFunc = function(html) { - var range = document.createRange(); - var start = document.getElementById(this.start); + // If we have the W3C range API, this process is relatively straight forward. + if (supportsRange) { + + // Get a range for the current morph. Optionally include the starting and + // ending placeholders. + rangeFor = function(morph, outerToo) { + var range = document.createRange(); + var before = document.getElementById(morph.start); + var after = document.getElementById(morph.end); + + if (outerToo) { + range.setStartBefore(before); + range.setEndAfter(after); + } else { + range.setStartAfter(before); + range.setEndBefore(after); + } - range.setStartAfter(start); - range.setEndAfter(start); + return range; + }; - var fragment = range.createContextualFragment(html); - range.insertNode(fragment); - }; + htmlFunc = function(html, outerToo) { + // get a range for the current metamorph object + var range = rangeFor(this, outerToo); - } else { - /** - * This code is mostly taken from jQuery, with one exception. In jQuery's case, we - * have some HTML and we need to figure out how to convert it into some nodes. - * - * In this case, jQuery needs to scan the HTML looking for an opening tag and use - * that as the key for the wrap map. In our case, we know the parent node, and - * can use its type as the key for the wrap map. - **/ - var wrapMap = { - select: [ 1, "<select multiple='multiple'>", "</select>" ], - fieldset: [ 1, "<fieldset>", "</fieldset>" ], - table: [ 1, "<table>", "</table>" ], - tbody: [ 2, "<table><tbody>", "</tbody></table>" ], - tr: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], - colgroup: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], - map: [ 1, "<map>", "</map>" ], - _default: [ 0, "", "" ] - }; + // delete the contents of the range, which will be the + // nodes between the starting and ending placeholder. + range.deleteContents(); - var findChildById = function(element, id) { - if (element.getAttribute('id') === id) { return element; } + // create a new document fragment for the HTML + var fragment = range.createContextualFragment(html); - var len = element.childNodes.length, idx, node, found; - for (idx=0; idx<len; idx++) { - node = element.childNodes[idx]; - found = node.nodeType === 1 && findChildById(node, id); - if (found) { return found; } - } - }; + // insert the fragment into the range + range.insertNode(fragment); + }; - var setInnerHTML = function(element, html) { - var matches = []; - if (movesWhitespace) { - // Right now we only check for script tags with ids with the - // goal of targeting morphs. - html = html.replace(/(\s+)(<script id='([^']+)')/g, function(match, spaces, tag, id) { - matches.push([id, spaces]); - return tag; - }); - } + removeFunc = function() { + // get a range for the current metamorph object including + // the starting and ending placeholders. + var range = rangeFor(this, true); - element.innerHTML = html; + // delete the entire range. + range.deleteContents(); + }; - // If we have to do any whitespace adjustments do them now - if (matches.length > 0) { - var len = matches.length, idx; - for (idx=0; idx<len; idx++) { - var script = findChildById(element, matches[idx][0]), - node = document.createTextNode(matches[idx][1]); - script.parentNode.insertBefore(node, script); - } - } - }; + appendToFunc = function(node) { + var range = document.createRange(); + range.setStart(node); + range.collapse(false); + var frag = range.createContextualFragment(this.outerHTML()); + node.appendChild(frag); + }; - /** - * Given a parent node and some HTML, generate a set of nodes. Return the first - * node, which will allow us to traverse the rest using nextSibling. - * - * We need to do this because innerHTML in IE does not really parse the nodes. - **/ - var firstNodeFor = function(parentNode, html) { - var arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default; - var depth = arr[0], start = arr[1], end = arr[2]; + afterFunc = function(html) { + var range = document.createRange(); + var after = document.getElementById(this.end); - if (needsShy) { html = '&shy;'+html; } + range.setStartAfter(after); + range.setEndAfter(after); - var element = document.createElement('div'); + var fragment = range.createContextualFragment(html); + range.insertNode(fragment); + }; - setInnerHTML(element, start + html + end); + prependFunc = function(html) { + var range = document.createRange(); + var start = document.getElementById(this.start); - for (var i=0; i<=depth; i++) { - element = element.firstChild; - } + range.setStartAfter(start); + range.setEndAfter(start); - // Look for &shy; to remove it. - if (needsShy) { - var shyElement = element; + var fragment = range.createContextualFragment(html); + range.insertNode(fragment); + }; - // Sometimes we get nameless elements with the shy inside - while (shyElement.nodeType === 1 && !shyElement.nodeName) { - shyElement = shyElement.firstChild; + } else { + /** + * This code is mostly taken from jQuery, with one exception. In jQuery's case, we + * have some HTML and we need to figure out how to convert it into some nodes. + * + * In this case, jQuery needs to scan the HTML looking for an opening tag and use + * that as the key for the wrap map. In our case, we know the parent node, and + * can use its type as the key for the wrap map. + **/ + var wrapMap = { + select: [ 1, "<select multiple='multiple'>", "</select>" ], + fieldset: [ 1, "<fieldset>", "</fieldset>" ], + table: [ 1, "<table>", "</table>" ], + tbody: [ 2, "<table><tbody>", "</tbody></table>" ], + tr: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], + colgroup: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], + map: [ 1, "<map>", "</map>" ], + _default: [ 0, "", "" ] + }; + + var findChildById = function(element, id) { + if (element.getAttribute('id') === id) { return element; } + + var len = element.childNodes.length, idx, node, found; + for (idx=0; idx<len; idx++) { + node = element.childNodes[idx]; + found = node.nodeType === 1 && findChildById(node, id); + if (found) { return found; } } - - // At this point it's the actual unicode character. - if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === "\u00AD") { - shyElement.nodeValue = shyElement.nodeValue.slice(1); + }; + + var setInnerHTML = function(element, html) { + var matches = []; + if (movesWhitespace) { + // Right now we only check for script tags with ids with the + // goal of targeting morphs. + html = html.replace(/(\s+)(<script id='([^']+)')/g, function(match, spaces, tag, id) { + matches.push([id, spaces]); + return tag; + }); } - } - return element; - }; + element.innerHTML = html; - /** - * In some cases, Internet Explorer can create an anonymous node in - * the hierarchy with no tagName. You can create this scenario via: - * - * div = document.createElement("div"); - * div.innerHTML = "<table>&shy<script></script><tr><td>hi</td></tr></table>"; - * div.firstChild.firstChild.tagName //=> "" - * - * If our script markers are inside such a node, we need to find that - * node and use *it* as the marker. - **/ - var realNode = function(start) { - while (start.parentNode.tagName === "") { - start = start.parentNode; - } + // If we have to do any whitespace adjustments do them now + if (matches.length > 0) { + var len = matches.length, idx; + for (idx=0; idx<len; idx++) { + var script = findChildById(element, matches[idx][0]), + node = document.createTextNode(matches[idx][1]); + script.parentNode.insertBefore(node, script); + } + } + }; - return start; - }; + /** + * Given a parent node and some HTML, generate a set of nodes. Return the first + * node, which will allow us to traverse the rest using nextSibling. + * + * We need to do this because innerHTML in IE does not really parse the nodes. + **/ + var firstNodeFor = function(parentNode, html) { + var arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default; + var depth = arr[0], start = arr[1], end = arr[2]; - /** - * When automatically adding a tbody, Internet Explorer inserts the - * tbody immediately before the first <tr>. Other browsers create it - * before the first node, no matter what. - * - * This means the the following code: - * - * div = document.createElement("div"); - * div.innerHTML = "<table><script id='first'></script><tr><td>hi</td></tr><script id='last'></script></table> - * - * Generates the following DOM in IE: - * - * + div - * + table - * - script id='first' - * + tbody - * + tr - * + td - * - "hi" - * - script id='last' - * - * Which means that the two script tags, even though they were - * inserted at the same point in the hierarchy in the original - * HTML, now have different parents. - * - * This code reparents the first script tag by making it the tbody's - * first child. - **/ - var fixParentage = function(start, end) { - if (start.parentNode !== end.parentNode) { - end.parentNode.insertBefore(start, end.parentNode.firstChild); - } - }; + if (needsShy) { html = '&shy;'+html; } - htmlFunc = function(html, outerToo) { - // get the real starting node. see realNode for details. - var start = realNode(document.getElementById(this.start)); - var end = document.getElementById(this.end); - var parentNode = end.parentNode; - var node, nextSibling, last; - - // make sure that the start and end nodes share the same - // parent. If not, fix it. - fixParentage(start, end); - - // remove all of the nodes after the starting placeholder and - // before the ending placeholder. - node = start.nextSibling; - while (node) { - nextSibling = node.nextSibling; - last = node === end; - - // if this is the last node, and we want to remove it as well, - // set the `end` node to the next sibling. This is because - // for the rest of the function, we insert the new nodes - // before the end (note that insertBefore(node, null) is - // the same as appendChild(node)). - // - // if we do not want to remove it, just break. - if (last) { - if (outerToo) { end = node.nextSibling; } else { break; } - } + var element = document.createElement('div'); - node.parentNode.removeChild(node); + setInnerHTML(element, start + html + end); - // if this is the last node and we didn't break before - // (because we wanted to remove the outer nodes), break - // now. - if (last) { break; } + for (var i=0; i<=depth; i++) { + element = element.firstChild; + } - node = nextSibling; - } + // Look for &shy; to remove it. + if (needsShy) { + var shyElement = element; - // get the first node for the HTML string, even in cases like - // tables and lists where a simple innerHTML on a div would - // swallow some of the content. - node = firstNodeFor(start.parentNode, html); - - // copy the nodes for the HTML between the starting and ending - // placeholder. - while (node) { - nextSibling = node.nextSibling; - parentNode.insertBefore(node, end); - node = nextSibling; - } - }; + // Sometimes we get nameless elements with the shy inside + while (shyElement.nodeType === 1 && !shyElement.nodeName) { + shyElement = shyElement.firstChild; + } - // remove the nodes in the DOM representing this metamorph. - // - // this includes the starting and ending placeholders. - removeFunc = function() { - var start = realNode(document.getElementById(this.start)); - var end = document.getElementById(this.end); - - this.html(''); - start.parentNode.removeChild(start); - end.parentNode.removeChild(end); - }; + // At this point it's the actual unicode character. + if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === "\u00AD") { + shyElement.nodeValue = shyElement.nodeValue.slice(1); + } + } - appendToFunc = function(parentNode) { - var node = firstNodeFor(parentNode, this.outerHTML()); + return element; + }; + + /** + * In some cases, Internet Explorer can create an anonymous node in + * the hierarchy with no tagName. You can create this scenario via: + * + * div = document.createElement("div"); + * div.innerHTML = "<table>&shy<script></script><tr><td>hi</td></tr></table>"; + * div.firstChild.firstChild.tagName //=> "" + * + * If our script markers are inside such a node, we need to find that + * node and use *it* as the marker. + **/ + var realNode = function(start) { + while (start.parentNode.tagName === "") { + start = start.parentNode; + } - while (node) { - nextSibling = node.nextSibling; - parentNode.appendChild(node); - node = nextSibling; - } - }; + return start; + }; + + /** + * When automatically adding a tbody, Internet Explorer inserts the + * tbody immediately before the first <tr>. Other browsers create it + * before the first node, no matter what. + * + * This means the the following code: + * + * div = document.createElement("div"); + * div.innerHTML = "<table><script id='first'></script><tr><td>hi</td></tr><script id='last'></script></table> + * + * Generates the following DOM in IE: + * + * + div + * + table + * - script id='first' + * + tbody + * + tr + * + td + * - "hi" + * - script id='last' + * + * Which means that the two script tags, even though they were + * inserted at the same point in the hierarchy in the original + * HTML, now have different parents. + * + * This code reparents the first script tag by making it the tbody's + * first child. + **/ + var fixParentage = function(start, end) { + if (start.parentNode !== end.parentNode) { + end.parentNode.insertBefore(start, end.parentNode.firstChild); + } + }; + + htmlFunc = function(html, outerToo) { + // get the real starting node. see realNode for details. + var start = realNode(document.getElementById(this.start)); + var end = document.getElementById(this.end); + var parentNode = end.parentNode; + var node, nextSibling, last; + + // make sure that the start and end nodes share the same + // parent. If not, fix it. + fixParentage(start, end); + + // remove all of the nodes after the starting placeholder and + // before the ending placeholder. + node = start.nextSibling; + while (node) { + nextSibling = node.nextSibling; + last = node === end; + + // if this is the last node, and we want to remove it as well, + // set the `end` node to the next sibling. This is because + // for the rest of the function, we insert the new nodes + // before the end (note that insertBefore(node, null) is + // the same as appendChild(node)). + // + // if we do not want to remove it, just break. + if (last) { + if (outerToo) { end = node.nextSibling; } else { break; } + } + + node.parentNode.removeChild(node); + + // if this is the last node and we didn't break before + // (because we wanted to remove the outer nodes), break + // now. + if (last) { break; } + + node = nextSibling; + } - afterFunc = function(html) { - // get the real starting node. see realNode for details. - var end = document.getElementById(this.end); - var insertBefore = end.nextSibling; - var parentNode = end.parentNode; - var nextSibling; - var node; - - // get the first node for the HTML string, even in cases like - // tables and lists where a simple innerHTML on a div would - // swallow some of the content. - node = firstNodeFor(parentNode, html); - - // copy the nodes for the HTML between the starting and ending - // placeholder. - while (node) { - nextSibling = node.nextSibling; - parentNode.insertBefore(node, insertBefore); - node = nextSibling; - } - }; + // get the first node for the HTML string, even in cases like + // tables and lists where a simple innerHTML on a div would + // swallow some of the content. + node = firstNodeFor(start.parentNode, html); + + // copy the nodes for the HTML between the starting and ending + // placeholder. + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, end); + node = nextSibling; + } + }; + + // remove the nodes in the DOM representing this metamorph. + // + // this includes the starting and ending placeholders. + removeFunc = function() { + var start = realNode(document.getElementById(this.start)); + var end = document.getElementById(this.end); + + this.html(''); + start.parentNode.removeChild(start); + end.parentNode.removeChild(end); + }; + + appendToFunc = function(parentNode) { + var node = firstNodeFor(parentNode, this.outerHTML()); + var nextSibling; + + while (node) { + nextSibling = node.nextSibling; + parentNode.appendChild(node); + node = nextSibling; + } + }; + + afterFunc = function(html) { + // get the real starting node. see realNode for details. + var end = document.getElementById(this.end); + var insertBefore = end.nextSibling; + var parentNode = end.parentNode; + var nextSibling; + var node; + + // get the first node for the HTML string, even in cases like + // tables and lists where a simple innerHTML on a div would + // swallow some of the content. + node = firstNodeFor(parentNode, html); + + // copy the nodes for the HTML between the starting and ending + // placeholder. + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, insertBefore); + node = nextSibling; + } + }; - prependFunc = function(html) { - var start = document.getElementById(this.start); - var parentNode = start.parentNode; - var nextSibling; - var node; + prependFunc = function(html) { + var start = document.getElementById(this.start); + var parentNode = start.parentNode; + var nextSibling; + var node; - node = firstNodeFor(parentNode, html); - var insertBefore = start.nextSibling; + node = firstNodeFor(parentNode, html); + var insertBefore = start.nextSibling; - while (node) { - nextSibling = node.nextSibling; - parentNode.insertBefore(node, insertBefore); - node = nextSibling; - } + while (node) { + nextSibling = node.nextSibling; + parentNode.insertBefore(node, insertBefore); + node = nextSibling; + } + }; } - } - - Metamorph.prototype.html = function(html) { - this.checkRemoved(); - if (html === undefined) { return this.innerHTML; } - htmlFunc.call(this, html); + Metamorph.prototype.html = function(html) { + this.checkRemoved(); + if (html === undefined) { return this.innerHTML; } - this.innerHTML = html; - }; + htmlFunc.call(this, html); - Metamorph.prototype.replaceWith = function(html) { - this.checkRemoved(); - htmlFunc.call(this, html, true); - }; + this.innerHTML = html; + }; - Metamorph.prototype.remove = removeFunc; - Metamorph.prototype.outerHTML = outerHTMLFunc; - Metamorph.prototype.appendTo = appendToFunc; - Metamorph.prototype.after = afterFunc; - Metamorph.prototype.prepend = prependFunc; - Metamorph.prototype.startTag = startTagFunc; - Metamorph.prototype.endTag = endTagFunc; + Metamorph.prototype.replaceWith = function(html) { + this.checkRemoved(); + htmlFunc.call(this, html, true); + }; - Metamorph.prototype.isRemoved = function() { - var before = document.getElementById(this.start); - var after = document.getElementById(this.end); + Metamorph.prototype.remove = removeFunc; + Metamorph.prototype.outerHTML = outerHTMLFunc; + Metamorph.prototype.appendTo = appendToFunc; + Metamorph.prototype.after = afterFunc; + Metamorph.prototype.prepend = prependFunc; + Metamorph.prototype.startTag = startTagFunc; + Metamorph.prototype.endTag = endTagFunc; - return !before || !after; - }; + Metamorph.prototype.isRemoved = function() { + var before = document.getElementById(this.start); + var after = document.getElementById(this.end); - Metamorph.prototype.checkRemoved = function() { - if (this.isRemoved()) { - throw new Error("Cannot perform operations on a Metamorph that is not in the DOM."); - } - }; + return !before || !after; + }; - return Metamorph; -}); + Metamorph.prototype.checkRemoved = function() { + if (this.isRemoved()) { + throw new Error("Cannot perform operations on a Metamorph that is not in the DOM."); + } + }; + return Metamorph; + });
false
Other
emberjs
ember.js
8714394fd9ced690512b2b5ae9a795b6ff2d5136.json
Fix a bug with item controllers. The shadow array of subcontainers was out of sync when array observers were fired.
packages/ember-runtime/lib/controllers/array_controller.js
@@ -158,8 +158,6 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, }, arrayContentDidChange: function(idx, removedCnt, addedCnt) { - this._super(idx, removedCnt, addedCnt); - var subContainers = get(this, 'subContainers'), subContainersToRemove = subContainers.slice(idx, idx+removedCnt); @@ -168,6 +166,11 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, }); replace(subContainers, idx, removedCnt, new Array(addedCnt)); + + // The shadow array of subcontainers must be updated before we trigger + // observers, otherwise observers will get the wrong subcontainer when + // calling `objectAt` + this._super(idx, removedCnt, addedCnt); }, init: function() {
true
Other
emberjs
ember.js
8714394fd9ced690512b2b5ae9a795b6ff2d5136.json
Fix a bug with item controllers. The shadow array of subcontainers was out of sync when array observers were fired.
packages/ember-runtime/tests/controllers/item_controller_class_test.js
@@ -223,3 +223,30 @@ test("if `lookupItemController` returns a string, it must be resolvable by the c /NonExistant/, "`lookupItemController` must return either null or a valid controller name"); }); + +test("array observers can invoke `objectAt` without overwriting existing item controllers", function() { + createArrayController(); + + var tywinController = arrayController.objectAtContent(0), + arrayObserverCalled = false; + + arrayController.reopen({ + lannistersWillChange: Ember.K, + lannistersDidChange: function(_, idx, removedAmt, addedAmt) { + arrayObserverCalled = true; + equal(this.objectAt(idx).get('name'), "Tyrion", "Array observers get the right object via `objectAt`"); + } + }); + arrayController.addArrayObserver(arrayController, { + willChange: 'lannistersWillChange', + didChange: 'lannistersDidChange' + }); + + Ember.run(function() { + lannisters.unshiftObject(tyrion); + }); + + equal(arrayObserverCalled, true, "Array observers are called normally"); + equal(tywinController.get('name'), "Tywin", "Array observers calling `objectAt` does not overwrite existing controllers' content"); +}); +
true
Other
emberjs
ember.js
494bbbb33154e8bd3201959112974b008657e557.json
Refine Ember.aliasMethod tests
packages/ember-metal/tests/mixin/alias_method_test.js
@@ -1,20 +1,13 @@ module('Ember.aliasMethod'); function validateAliasMethod(obj) { - var get = Ember.get; - equal(get(obj, 'foo'), 'foo', 'obj.foo'); - equal(get(obj, 'bar'), 'foo', 'obj.bar should be a copy of foo'); - equal(obj.fooMethod(), 'FOO', 'obj.fooMethod()'); equal(obj.barMethod(), 'FOO', 'obj.barMethod should be a copy of foo'); } -test('copies the property values from another key when the mixin is applied', function() { +test('methods of another name are aliased when the mixin is applied', function() { var MyMixin = Ember.Mixin.create({ - foo: 'foo', - bar: Ember.aliasMethod('foo'), - fooMethod: function() { return 'FOO'; }, barMethod: Ember.aliasMethod('fooMethod') }); @@ -26,52 +19,46 @@ test('copies the property values from another key when the mixin is applied', fu test('should follow aliasMethods all the way down', function() { var MyMixin = Ember.Mixin.create({ bar: Ember.aliasMethod('foo'), // put first to break ordered iteration - baz: 'baz', + baz: function(){ return 'baz'; }, foo: Ember.aliasMethod('baz') }); var obj = MyMixin.apply({}); - equal(Ember.get(obj, 'bar'), 'baz', 'should have followed aliasMethods'); + equal(Ember.get(obj, 'bar')(), 'baz', 'should have followed aliasMethods'); }); -test('should copy from other dependent mixins', function() { +test('should alias methods from other dependent mixins', function() { var BaseMixin = Ember.Mixin.create({ - foo: 'foo', - fooMethod: function() { return 'FOO'; } }); var MyMixin = Ember.Mixin.create(BaseMixin, { - bar: Ember.aliasMethod('foo'), barMethod: Ember.aliasMethod('fooMethod') }); var obj = MyMixin.apply({}); validateAliasMethod(obj); }); -test('should copy from other mixins applied at same time', function() { +test('should alias methods from other mixins applied at same time', function() { var BaseMixin = Ember.Mixin.create({ - foo: 'foo', - fooMethod: function() { return 'FOO'; } }); var MyMixin = Ember.Mixin.create({ - bar: Ember.aliasMethod('foo'), barMethod: Ember.aliasMethod('fooMethod') }); var obj = Ember.mixin({}, BaseMixin, MyMixin); validateAliasMethod(obj); }); -test('should copy from properties already applied on object', function() { +test('should alias methods from mixins already applied on object', function() { var BaseMixin = Ember.Mixin.create({ - foo: 'foo' + quxMethod: function() { return 'qux'; } }); var MyMixin = Ember.Mixin.create({
false
Other
emberjs
ember.js
b53c217705331c2594faa780a83434b74ca7061f.json
Improve Docs of Ember.alias and Ember.aliasMethod
packages/ember-metal/lib/mixin.js
@@ -543,11 +543,11 @@ Alias.prototype = new Ember.Descriptor(); ```javascript App.PaintSample = Ember.Object.extend({ color: 'red', - colour: Ember.aliasMethod('color'), + colour: Ember.alias('color'), name: function(){ return "Zed"; }, - moniker: Ember.aliasMethod("name") + moniker: Ember.alias("name") }); var paintSample = App.PaintSample.create() @@ -559,33 +559,31 @@ Alias.prototype = new Ember.Descriptor(); @for Ember @param {String} methodName name of the method or property to alias @return {Ember.Descriptor} + @deprecated Use `Ember.aliasMethod` or `Ember.computed.alias` instead */ Ember.alias = function(methodName) { return new Alias(methodName); }; + Ember.deprecateFunc("Ember.alias is deprecated. Please use Ember.aliasMethod or Ember.computed.alias instead.", Ember.alias); /** - Makes a property or method available via an additional name. + Makes a method available via an additional name. ```javascript - App.PaintSample = Ember.Object.extend({ - color: 'red', - colour: Ember.aliasMethod('color'), + App.Person = Ember.Object.extend({ name: function(){ - return "Zed"; + return 'Tomhuda Katzdale'; }, - moniker: Ember.aliasMethod("name") + moniker: Ember.aliasMethod('name') }); - var paintSample = App.PaintSample.create() - paintSample.get('colour'); // 'red' - paintSample.moniker(); // 'Zed' + var goodGuy = App.Person.create() ``` @method aliasMethod @for Ember - @param {String} methodName name of the method or property to alias + @param {String} methodName name of the method to alias @return {Ember.Descriptor} */ Ember.aliasMethod = function(methodName) {
false
Other
emberjs
ember.js
32c1d6b1d0f0b83511691435a48a7b7282737ab7.json
Clarify itemController out of range case.
packages/ember-runtime/lib/controllers/array_controller.js
@@ -142,6 +142,12 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, if (controllerClass && idx < length) { return this.controllerAt(idx, object, controllerClass); } else { + // When controllerClass is falsy we have not opted in to using item + // controllers, so return the object directly. However, when + // controllerClass is defined but the index is out of range, we want to + // return the "out of range" value, whatever that might be. Rather than + // make assumptions (e.g. guessing `null` or `undefined`) we defer this to + // `arrangedContent`. return object; } },
false
Other
emberjs
ember.js
075ed988996a79bc27f76fd1a582ac6cd94452b2.json
Fix trailing slash issue. Fixes #1691
packages/ember-routing/lib/vendor/route-recognizer.js
@@ -373,8 +373,14 @@ define("route-recognizer", // DEBUG GROUP path + var pathLen = path.length; + if (path.charAt(0) !== "/") { path = "/" + path; } + if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { + path = path.substr(0, pathLen - 1); + } + for (i=0, l=path.length; i<l; i++) { states = recognizeChar(states, path.charAt(i)); if (!states.length) { break; }
false
Other
emberjs
ember.js
971ac729a36eb4d495e34a9ef051cf6eadeed7f5.json
Update gitsubmodules urls to public repos.
.gitmodules
@@ -1,9 +1,9 @@ -[submodule "cookbooks/phantomjs"] - path = cookbooks/phantomjs - url = git@github.com:customink-webops/phantomjs.git [submodule "cookbooks/build-essential"] path = cookbooks/build-essential - url = git@github.com:opscode-cookbooks/build-essential.git + url = https://github.com/opscode-cookbooks/build-essential.git +[submodule "cookbooks/phantomjs"] + path = cookbooks/phantomjs + url = https://github.com/customink-webops/phantomjs.git [submodule "cookbooks/nodejs"] path = cookbooks/nodejs - url = git@github.com:mdxp/nodejs-cookbook.git + url = https://github.com/mdxp/nodejs-cookbook.git
false
Other
emberjs
ember.js
49dd221e8cc0453f0e6ba260b109d88108b927a4.json
Make `model` an alias for `content` on controllers
packages/ember-routing/lib/ext/controller.js
@@ -1,4 +1,4 @@ -var get = Ember.get; +var get = Ember.get, set = Ember.set; Ember.ControllerMixin.reopen({ concatenatedProperties: ['needs'], @@ -22,7 +22,15 @@ Ember.ControllerMixin.reopen({ controllerFor: function(controllerName) { var container = get(this, 'container'); return container.lookup('controller:' + controllerName); - } + }, + + model: Ember.computed(function(key, value) { + if (arguments.length > 1) { + return set(this, 'content', value); + } else { + return get(this, 'content'); + } + }).property('content') }); function verifyDependencies(controller) {
false
Other
emberjs
ember.js
335215bd5aab3e18e7d1fe7651cf7628b78d51ca.json
add test for SortableMixin bugfix
packages/ember-runtime/tests/mixins/sortable_test.js
@@ -195,6 +195,15 @@ test("don't remove and insert if position didn't change", function() { ok(!insertItemSortedCalled, "insertItemSorted should not have been called"); }); +test("sortProperties observers removed on content removal", function() { + var removedObject = unsortedArray.objectAt(2); + equal(Ember.listenersFor(removedObject, 'name:change').length, 1, + "Before removal, there should be one listener for sortProperty change."); + unsortedArray.replace(2, 1, []); + equal(Ember.listenersFor(removedObject, 'name:change').length, 0, + "After removal, there should be no listeners for sortProperty change."); +}); + module("Ember.Sortable with sortProperties", { setup: function() { Ember.run(function() {
false
Other
emberjs
ember.js
8f6000057475dc0011bebc61d0539146986bc9b2.json
Add needs to controllers
packages/ember-routing/lib/ext/controller.js
@@ -1,6 +1,18 @@ var get = Ember.get; Ember.ControllerMixin.reopen({ + concatenatedProperties: ['needs'], + needs: [], + + init: function() { + this._super.apply(this, arguments); + + // Structure asserts to still do verification but not string concat in production + if(!verifyDependencies(this)) { + Ember.assert("Missing dependencies", false); + } + }, + transitionTo: function() { var router = get(this, 'target'); @@ -12,3 +24,23 @@ Ember.ControllerMixin.reopen({ return container.lookup('controller:' + controllerName); } }); + +function verifyDependencies(controller) { + var needs = get(controller, 'needs'), + container = get(controller, 'container'), + dependency, satisfied = true; + + for (var i=0, l=needs.length; i<l; i++) { + dependency = needs[i]; + if (dependency.indexOf(':') === -1) { + dependency = "controller:" + dependency; + } + + if (!container.has(dependency)) { + satisfied = false; + Ember.assert(this + " needs " + dependency + " but it does not exist", false); + } + } + + return satisfied; +}
true
Other
emberjs
ember.js
8f6000057475dc0011bebc61d0539146986bc9b2.json
Add needs to controllers
packages/ember-routing/tests/system/controller.js
@@ -0,0 +1,33 @@ +module("Controller dependencies"); + +test("If a controller specifies a dependency, it is available to `controllerFor`", function() { + var container = new Ember.Container(); + + container.register('controller', 'post', Ember.Controller.extend({ + needs: 'posts', + + postsController: Ember.computed(function() { + return this.controllerFor('posts'); + }) + })); + + container.register('controller', 'posts', Ember.Controller.extend()); + + var postController = container.lookup('controller:post'), + postsController = container.lookup('controller:posts'); + + equal(postsController, postController.get('postsController'), "Getting dependency controllers work"); +}); + +test("If a controller specifies an unavailable dependency, it raises", function() { + var container = new Ember.Container(); + + container.register('controller', 'post', Ember.Controller.extend({ + needs: 'posts' + })); + + raises(function() { + container.lookup('controller:post'); + }, /controller:posts/); +}); +
true
Other
emberjs
ember.js
1bf0df4c95512dd42687a9b2b5ca3936a11aa09a.json
Add currentPath to applicationController
packages/ember-routing/lib/system/router.js
@@ -37,7 +37,8 @@ Ember.Router = Ember.Object.extend({ startRouting: function() { var router = this.router, location = get(this, 'location'), - container = this.container; + container = this.container, + self = this; var lastURL; @@ -51,6 +52,10 @@ Ember.Router = Ember.Object.extend({ Ember.run.once(updateURL); }; + router.didTransition = function(infos) { + self.didTransition(infos); + }; + container.register('view', 'default', DefaultView); container.register('view', 'toplevel', Ember.View.extend()); @@ -60,6 +65,17 @@ Ember.Router = Ember.Object.extend({ }); }, + didTransition: function(infos) { + var appController = this.container.lookup('controller:application'), + path = routePath(infos); + + set(appController, 'currentPath', path); + + if (get(this, 'namespace').LOG_TRANSITIONS) { + Ember.Logger.log("Transitioned into '" + path + "'"); + } + }, + handleURL: function(url) { this.router.handleURL(url); this.notifyPropertyChange('url'); @@ -134,6 +150,16 @@ function handlerIsActive(router, handlerName) { return false; } +function routePath(handlerInfos) { + var path = []; + + for (var i=1, l=handlerInfos.length; i<l; i++) { + path.push(handlerInfos[i].name); + } + + return path.join("."); +} + Ember.Router.reopenClass({ map: function(callback) { this.callback = callback;
true
Other
emberjs
ember.js
1bf0df4c95512dd42687a9b2b5ca3936a11aa09a.json
Add currentPath to applicationController
packages/ember-routing/lib/vendor/router.js
@@ -59,7 +59,7 @@ define("router", @param {String} url a URL to process - @returns {Array} an Array of `[handler, parameter]` tuples + @return {Array} an Array of `[handler, parameter]` tuples */ handleURL: function(url) { var results = this.recognizer.recognize(url), @@ -103,7 +103,7 @@ define("router", @param {String} handlerName @param {Array[Object]} contexts - @returns {Object} a serialized parameter hash + @return {Object} a serialized parameter hash */ paramsForHandler: function(handlerName, callback) { var output = this._paramsForHandler(handlerName, [].slice.call(arguments, 1)); @@ -118,7 +118,7 @@ define("router", a URL for @param {...Object} objects a list of objects to serialize - @returns {String} a URL + @return {String} a URL */ generate: function(handlerName) { var params = this.paramsForHandler.apply(this, arguments); @@ -375,6 +375,10 @@ define("router", handler.context = context; if (handler.setup) { handler.setup(context); } }); + + if (router.didTransition) { + router.didTransition(handlerInfos); + } } /** @@ -456,7 +460,7 @@ define("router", @param {Array[HandlerInfo]} newHandlers a list of the handler information for the new URL - @returns {Partition} + @return {Partition} */ function partitionHandlers(oldHandlers, newHandlers) { var handlers = {
true
Other
emberjs
ember.js
1bf0df4c95512dd42687a9b2b5ca3936a11aa09a.json
Add currentPath to applicationController
packages/ember/tests/routing/basic_test.js
@@ -47,12 +47,21 @@ test("The Homepage", function() { App.HomeRoute = Ember.Route.extend({ }); + var currentPath; + + App.ApplicationController = Ember.Route.extend({ + currentPathDidChange: Ember.observer(function() { + currentPath = get(this, 'currentPath'); + }, 'currentPath') + }); + bootApplication(); Ember.run(function() { router.handleURL("/"); }); + equal(currentPath, 'home'); equal(Ember.$('h3:contains(Hours)', '#qunit-fixture').length, 1, "The home template was rendered"); }); @@ -410,6 +419,14 @@ test("Nested callbacks are not exited when moving to siblings", function() { }); }); + var currentPath; + + App.ApplicationController = Ember.Route.extend({ + currentPathDidChange: Ember.observer(function() { + currentPath = get(this, 'currentPath'); + }, 'currentPath') + }); + var menuItem; App.MenuItem = Ember.Object.extend(Ember.DeferredMixin); @@ -489,6 +506,7 @@ test("Nested callbacks are not exited when moving to siblings", function() { equal(rootModel, 1, "The root model was called again"); deepEqual(router.location.path, '/specials/1'); + equal(currentPath, 'root.special'); }); asyncTest("Events are triggered on the controller if a matching action name is implemented", function() {
true
Other
emberjs
ember.js
c0311318c448b03d032f46a5cfc7f06318c4f29a.json
Add controllerFor on controllers
packages/ember-routing/lib/ext/controller.js
@@ -5,5 +5,10 @@ Ember.ControllerMixin.reopen({ var router = get(this, 'target'); return router.transitionTo.apply(router, arguments); + }, + + controllerFor: function(controllerName) { + var container = get(this, 'container'); + return container.lookup('controller:' + controllerName); } });
false
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember-application/lib/system/application.js
@@ -601,7 +601,6 @@ Ember.Application.reopenClass({ container.injection('router:main', 'namespace', 'application:main'); container.typeInjection('controller', 'target', 'router:main'); - container.typeInjection('controller', 'controllers', 'router:main'); container.typeInjection('controller', 'namespace', 'application:main'); container.typeInjection('route', 'router', 'router:main');
true
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember-old-router/lib/controller_ext.js
@@ -12,6 +12,7 @@ Additional methods for the ControllerMixin @namespace Ember */ Ember.ControllerMixin.reopen({ + controllers: null, /** `connectOutlet` creates a new instance of a provided view @@ -163,6 +164,31 @@ Ember.ControllerMixin.reopen({ return view; }, + /** + Convenience method to connect controllers. This method makes other controllers + available on the controller the method was invoked on. + + For example, to make the `personController` and the `postController` available + on the `overviewController`, you would call: + + ```javascript + overviewController.connectControllers('person', 'post'); + ``` + + @method connectControllers + @param {String...} controllerNames the controllers to make available + */ + connectControllers: function() { + var controllers = get(this, 'controllers'), + controllerNames = Array.prototype.slice.apply(arguments), + controllerName; + + for (var i=0, l=controllerNames.length; i<l; i++) { + controllerName = controllerNames[i] + 'Controller'; + set(this, controllerName, get(controllers, controllerName)); + } + }, + /** `disconnectOutlet` removes previously attached view from given outlet.
true
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember-old-router/tests/controller_test.js
@@ -191,3 +191,42 @@ test("can disconnect outlet from controller", function() { equal(appController.get('master'), null, "the app controller's master view is null"); }); + +module("Ember.Controller#connectControllers", { + setup: function() { + lookup = Ember.lookup = {}; + + Ember.run(function () { + lookup.TestApp = TestApp = Ember.Application.create(); + }); + + + TestApp.ApplicationController = Ember.Controller.extend(); + + TestApp.PostController = Ember.Controller.extend(); + TestApp.PostView = Ember.View.extend(); + }, + + teardown: function() { + Ember.run(function () { + lookup.TestApp.destroy(); + }); + Ember.lookup = originalLookup; + } +}); + +test("connectControllers injects other controllers", function() { + var postController = {}, commentController = {}; + + var controller = Ember.Controller.create({ + controllers: { + postController: postController, + commentController: commentController + } + }); + + controller.connectControllers('post', 'comment'); + + equal(controller.get('postController'), postController, "should connect postController"); + equal(controller.get('commentController'), commentController, "should connect commentController"); +});
true
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember-views/lib/system/controller.js
@@ -15,35 +15,8 @@ Additional methods for the ControllerMixin @namespace Ember */ Ember.ControllerMixin.reopen({ - target: null, - controllers: null, namespace: null, view: null, - container: null, - - /** - Convenience method to connect controllers. This method makes other controllers - available on the controller the method was invoked on. - - For example, to make the `personController` and the `postController` available - on the `overviewController`, you would call: - - ```javascript - overviewController.connectControllers('person', 'post'); - ``` - - @method connectControllers - @param {String...} controllerNames the controllers to make available - */ - connectControllers: function() { - var controllers = get(this, 'controllers'), - controllerNames = Array.prototype.slice.apply(arguments), - controllerName; - - for (var i=0, l=controllerNames.length; i<l; i++) { - controllerName = controllerNames[i] + 'Controller'; - set(this, controllerName, get(controllers, controllerName)); - } - } + container: null });
true
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember-views/tests/system/controller_test.js
@@ -1,40 +0,0 @@ -var originalLookup = Ember.lookup, TestApp, lookup; - -module("Ember.Controller#connectControllers", { - setup: function() { - lookup = Ember.lookup = {}; - - Ember.run(function () { - lookup.TestApp = TestApp = Ember.Application.create(); - }); - - - TestApp.ApplicationController = Ember.Controller.extend(); - - TestApp.PostController = Ember.Controller.extend(); - TestApp.PostView = Ember.View.extend(); - }, - - teardown: function() { - Ember.run(function () { - lookup.TestApp.destroy(); - }); - Ember.lookup = originalLookup; - } -}); - -test("connectControllers injects other controllers", function() { - var postController = {}, commentController = {}; - - var controller = Ember.Controller.create({ - controllers: { - postController: postController, - commentController: commentController - } - }); - - controller.connectControllers('post', 'comment'); - - equal(controller.get('postController'), postController, "should connect postController"); - equal(controller.get('commentController'), commentController, "should connect commentController"); -});
true
Other
emberjs
ember.js
0087cade0c720cf2b42d5b2d727762d34de2520c.json
Move connectControllers to old-router
packages/ember/tests/routing/basic_test.js
@@ -505,7 +505,7 @@ asyncTest("Events are triggered on the controller if a matching action name is i }, events: { - showStuff: function(handler, obj) { + showStuff: function(obj) { stateIsNotCalled = false; } } @@ -551,8 +551,8 @@ asyncTest("Events are triggered on the current state", function() { }, events: { - showStuff: function(handler, obj) { - ok(handler instanceof App.HomeRoute, "the handler is an App.HomeRoute"); + showStuff: function(obj) { + ok(this instanceof App.HomeRoute, "the handler is an App.HomeRoute"); // Using Ember.copy removes any private Ember vars which older IE would be confused by deepEqual(Ember.copy(obj, true), { name: "Tom Dale" }, "the context is correct"); start(); @@ -592,8 +592,8 @@ asyncTest("Events are triggered on the current state when routes are nested", fu App.RootRoute = Ember.Route.extend({ events: { - showStuff: function(handler, obj) { - ok(handler instanceof App.RootRoute, "the handler is an App.HomeRoute"); + showStuff: function(obj) { + ok(this instanceof App.RootRoute, "the handler is an App.HomeRoute"); // Using Ember.copy removes any private Ember vars which older IE would be confused by deepEqual(Ember.copy(obj, true), { name: "Tom Dale" }, "the context is correct"); start();
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
Assetfile
@@ -114,11 +114,25 @@ class VersionInfo < Rake::Pipeline::Filter end end +class EmberStub < Rake::Pipeline::Filter + def generate_output(inputs, output) + inputs.each do |input| + file = File.read(input.fullpath) + out = "(function() {\nvar Ember = { assert: function() {} };\n" + out << file + out << "\nexports.precompile = Ember.Handlebars.precompile;" + out << "\n})()" + output.write out + end + end +end + distros = { - "runtime" => %w(ember-metal ember-runtime), - "data-deps" => %w(ember-metal ember-runtime ember-states), - "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph ember-handlebars ember-routing ember-application ember-states), - "old-router" => %w(ember-metal rsvp ember-runtime ember-views ember-states ember-viewstates metamorph ember-handlebars ember-old-router ) + "runtime" => %w(ember-metal ember-runtime), + "template-compiler" => %w(handlebars ember-handlebars-compiler), + "data-deps" => %w(ember-metal ember-runtime ember-states), + "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph ember-handlebars-compiler ember-handlebars ember-routing ember-application ember-states), + "old-router" => %w(ember-metal rsvp ember-runtime ember-views ember-states ember-viewstates metamorph ember-handlebars-compiler ember-handlebars ember-old-router ) } output "dist" @@ -183,13 +197,14 @@ distros.each do |name, modules| module_paths = modules.map{|m| "#{m}.js" } match "{#{module_paths.join(',')}}" do concat(module_paths){ ["#{name}.js", "#{name}.prod.js"] } - filter AddMicroLoader + filter AddMicroLoader unless name == "ember-template-compiler" end # Add debug to the main distro match "{#{name}.js,ember-debug.js}" do filter VersionInfo - concat ["ember-debug.js"], "#{name}.js" + concat ["ember-debug.js"], "#{name}.js" unless name == "ember-template-compiler" + filter EmberStub if name == "ember-template-compiler" end # Strip dev code
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
Rakefile
@@ -74,6 +74,7 @@ task :test, [:suite] => :dist do |t, args| suites = { :default => packages.map{|p| "package=#{p}" }, + :built => [ "package=all&dist=build" ], :runtime => [ "package=ember-metal,ember-runtime" ], :views => [ "package=ember-views,ember-handlebars" ], :standard => packages.map{|p| "package=#{p}" } +
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/ember-handlebars-compiler/lib/main.js
@@ -0,0 +1,171 @@ +/** +@module ember +@submodule ember-handlebars +*/ + +// Eliminate dependency on any Ember to simplify precompilation workflow +var objectCreate = Object.create || function(parent) { + function F() {} + F.prototype = parent; + return new F(); +}; + +var Handlebars = this.Handlebars || Ember.imports.Handlebars; +Ember.assert("Ember Handlebars requires Handlebars 1.0.beta.5 or greater", Handlebars && Handlebars.VERSION.match(/^1\.0\.beta\.[56789]$|^1\.0\.rc\.[123456789]+/)); + +/** + Prepares the Handlebars templating library for use inside Ember's view + system. + + The `Ember.Handlebars` object is the standard Handlebars library, extended to + use Ember's `get()` method instead of direct property access, which allows + computed properties to be used inside templates. + + To create an `Ember.Handlebars` template, call `Ember.Handlebars.compile()`. + This will return a function that can be used by `Ember.View` for rendering. + + @class Handlebars + @namespace Ember +*/ +Ember.Handlebars = objectCreate(Handlebars); + +/** +@class helpers +@namespace Ember.Handlebars +*/ +Ember.Handlebars.helpers = objectCreate(Handlebars.helpers); + +/** + Override the the opcode compiler and JavaScript compiler for Handlebars. + + @class Compiler + @namespace Ember.Handlebars + @private + @constructor +*/ +Ember.Handlebars.Compiler = function() {}; + +// Handlebars.Compiler doesn't exist in runtime-only +if (Handlebars.Compiler) { + Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); +} + +Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler; + +/** + @class JavaScriptCompiler + @namespace Ember.Handlebars + @private + @constructor +*/ +Ember.Handlebars.JavaScriptCompiler = function() {}; + +// Handlebars.JavaScriptCompiler doesn't exist in runtime-only +if (Handlebars.JavaScriptCompiler) { + Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); + Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler; +} + + +Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; + + +Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { + return "''"; +}; + +/** + @private + + Override the default buffer for Ember Handlebars. By default, Handlebars + creates an empty String at the beginning of each invocation and appends to + it. Ember's Handlebars overrides this to append to a single shared buffer. + + @method appendToBuffer + @param string {String} +*/ +Ember.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) { + return "data.buffer.push("+string+");"; +}; + +/** + @private + + Rewrite simple mustaches from `{{foo}}` to `{{bind "foo"}}`. This means that + all simple mustaches in Ember's Handlebars will also set up an observer to + keep the DOM up to date when the underlying property changes. + + @method mustache + @for Ember.Handlebars.Compiler + @param mustache +*/ +Ember.Handlebars.Compiler.prototype.mustache = function(mustache) { + if (mustache.params.length || mustache.hash) { + return Handlebars.Compiler.prototype.mustache.call(this, mustache); + } else { + var id = new Handlebars.AST.IdNode(['_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 + // changes and we need to re-render the value. + if(!mustache.escaped) { + mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]); + mustache.hash.pairs.push(["unescaped", new Handlebars.AST.StringNode("true")]); + } + mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped); + return Handlebars.Compiler.prototype.mustache.call(this, mustache); + } +}; + +/** + Used for precompilation of Ember Handlebars templates. This will not be used + during normal app execution. + + @method precompile + @for Ember.Handlebars + @static + @param {String} string The template to precompile +*/ +Ember.Handlebars.precompile = function(string) { + var ast = Handlebars.parse(string); + + var options = { + knownHelpers: { + action: true, + unbound: true, + bindAttr: true, + template: true, + view: true, + _triageMustache: true + }, + data: true, + stringParams: true + }; + + var environment = new Ember.Handlebars.Compiler().compile(ast, options); + return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); +}; + +// We don't support this for Handlebars runtime-only +if (Handlebars.compile) { + /** + The entry point for Ember Handlebars. This replaces the default + `Handlebars.compile` and turns on template-local data and String + parameters. + + @method compile + @for Ember.Handlebars + @static + @param {String} string The template to compile + @return {Function} + */ + Ember.Handlebars.compile = function(string) { + var ast = Handlebars.parse(string); + var options = { data: true, stringParams: true }; + var environment = new Ember.Handlebars.Compiler().compile(ast, options); + var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); + + return Handlebars.template(templateSpec); + }; +} +
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/ember-handlebars-compiler/package.json
@@ -0,0 +1,35 @@ +{ + "name": "ember-handlebars-compiler", + "summary": "Ember Handlebars Compiler", + "description": "A programmatic compiler for Handlebars with the few syntax extensions supported by Ember with minimal dependencies", + "homepage": "http://emberjs.com", + "author": "Yehuda Katz", + "version": "1.0.0-pre.2", + "dependencies": { + "spade": "~> 1.0.0", + "handlebars": "~> 1.0.0.beta.6" + }, + + "directories": { + "lib": "lib" + }, + + "dependencies:development": { + "spade-qunit": "~> 1.0.0" + }, + + "bpm:build": { + + "bpm_libs.js": { + "files": ["lib"], + "modes": "*" + }, + + "ember-handlebars/bpm_tests.js": { + "files": ["tests"], + "modes": ["debug"] + } + } + +} +
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/ember-handlebars/lib/ext.js
@@ -1,170 +1,4 @@ -require("ember-views/system/render_buffer"); - -/** -@module ember -@submodule ember-handlebars -*/ - -var objectCreate = Ember.create; - -var Handlebars = Ember.imports.Handlebars; -Ember.assert("Ember Handlebars requires Handlebars 1.0.beta.5 or greater", Handlebars && Handlebars.VERSION.match(/^1\.0\.beta\.[56789]$|^1\.0\.rc\.[123456789]+/)); - -/** - Prepares the Handlebars templating library for use inside Ember's view - system. - - The `Ember.Handlebars` object is the standard Handlebars library, extended to - use Ember's `get()` method instead of direct property access, which allows - computed properties to be used inside templates. - - To create an `Ember.Handlebars` template, call `Ember.Handlebars.compile()`. - This will return a function that can be used by `Ember.View` for rendering. - - @class Handlebars - @namespace Ember -*/ -Ember.Handlebars = objectCreate(Handlebars); - -/** -@class helpers -@namespace Ember.Handlebars -*/ -Ember.Handlebars.helpers = objectCreate(Handlebars.helpers); - -/** - Override the the opcode compiler and JavaScript compiler for Handlebars. - - @class Compiler - @namespace Ember.Handlebars - @private - @constructor -*/ -Ember.Handlebars.Compiler = function() {}; - -// Handlebars.Compiler doesn't exist in runtime-only -if (Handlebars.Compiler) { - Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); -} - -Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler; - -/** - @class JavaScriptCompiler - @namespace Ember.Handlebars - @private - @constructor -*/ -Ember.Handlebars.JavaScriptCompiler = function() {}; - -// Handlebars.JavaScriptCompiler doesn't exist in runtime-only -if (Handlebars.JavaScriptCompiler) { - Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); - Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler; -} - - -Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; - - -Ember.Handlebars.JavaScriptCompiler.prototype.initializeBuffer = function() { - return "''"; -}; - -/** - @private - - Override the default buffer for Ember Handlebars. By default, Handlebars - creates an empty String at the beginning of each invocation and appends to - it. Ember's Handlebars overrides this to append to a single shared buffer. - - @method appendToBuffer - @param string {String} -*/ -Ember.Handlebars.JavaScriptCompiler.prototype.appendToBuffer = function(string) { - return "data.buffer.push("+string+");"; -}; - -/** - @private - - Rewrite simple mustaches from `{{foo}}` to `{{bind "foo"}}`. This means that - all simple mustaches in Ember's Handlebars will also set up an observer to - keep the DOM up to date when the underlying property changes. - - @method mustache - @for Ember.Handlebars.Compiler - @param mustache -*/ -Ember.Handlebars.Compiler.prototype.mustache = function(mustache) { - if (mustache.params.length || mustache.hash) { - return Handlebars.Compiler.prototype.mustache.call(this, mustache); - } else { - var id = new Handlebars.AST.IdNode(['_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 - // changes and we need to re-render the value. - if(!mustache.escaped) { - mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]); - mustache.hash.pairs.push(["unescaped", new Handlebars.AST.StringNode("true")]); - } - mustache = new Handlebars.AST.MustacheNode([id].concat([mustache.id]), mustache.hash, !mustache.escaped); - return Handlebars.Compiler.prototype.mustache.call(this, mustache); - } -}; - -/** - Used for precompilation of Ember Handlebars templates. This will not be used - during normal app execution. - - @method precompile - @for Ember.Handlebars - @static - @param {String} string The template to precompile -*/ -Ember.Handlebars.precompile = function(string) { - var ast = Handlebars.parse(string); - - var options = { - knownHelpers: { - action: true, - unbound: true, - bindAttr: true, - template: true, - view: true, - _triageMustache: true - }, - data: true, - stringParams: true - }; - - var environment = new Ember.Handlebars.Compiler().compile(ast, options); - return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); -}; - -// We don't support this for Handlebars runtime-only -if (Handlebars.compile) { - /** - The entry point for Ember Handlebars. This replaces the default - `Handlebars.compile` and turns on template-local data and String - parameters. - - @method compile - @for Ember.Handlebars - @static - @param {String} string The template to compile - @return {Function} - */ - Ember.Handlebars.compile = function(string) { - var ast = Handlebars.parse(string); - var options = { data: true, stringParams: true }; - var environment = new Ember.Handlebars.Compiler().compile(ast, options); - var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); - - return Handlebars.template(templateSpec); - }; -} +require('ember-handlebars-compiler'); /** @private
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/ember-handlebars/lib/main.js
@@ -1,3 +1,4 @@ +require("ember-handlebars-compiler"); require("ember-runtime"); require("ember-views"); require("ember-handlebars/ext");
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/ember-handlebars/package.json
@@ -7,7 +7,7 @@ "version": "1.0.0-pre.2", "dependencies": { "spade": "~> 1.0.0", - "handlebars": "~> 1.0.0.beta.6", + "ember-handlebars-compiler", "1.0.0-pre.2", "ember-views": "1.0.0-pre.2", "metamorph": "~> 1.0.0" },
true
Other
emberjs
ember.js
3fe33981e67baf226ef0afe27e02c4a3b9294a29.json
Provide a precompilation package This should make it easier to maintain external precompilers without stubbing out parts of Ember
packages/handlebars/lib/main.js
@@ -0,0 +1,1937 @@ +// lib/handlebars/base.js + +/*jshint eqnull:true*/ +this.Handlebars = {}; + +(function(Handlebars) { + +Handlebars.VERSION = "1.0.rc.1"; + +Handlebars.helpers = {}; +Handlebars.partials = {}; + +Handlebars.registerHelper = function(name, fn, inverse) { + if(inverse) { fn.not = inverse; } + this.helpers[name] = fn; +}; + +Handlebars.registerPartial = function(name, str) { + this.partials[name] = str; +}; + +Handlebars.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Error("Could not find property '" + arg + "'"); + } +}); + +var toString = Object.prototype.toString, functionType = "[object Function]"; + +Handlebars.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + + var ret = ""; + var type = toString.call(context); + + if(type === functionType) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if(type === "[object Array]") { + if(context.length > 0) { + return Handlebars.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } +}); + +Handlebars.K = function() {}; + +Handlebars.createFrame = Object.create || function(object) { + Handlebars.K.prototype = object; + var obj = new Handlebars.K(); + Handlebars.K.prototype = null; + return obj; +}; + +Handlebars.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (options.data) { + data = Handlebars.createFrame(options.data); + } + + if(context && typeof context === 'object') { + if(context instanceof Array){ + for(var j = context.length; i<j; i++) { + if (data) { data.index = i; } + ret = ret + fn(context[i], { data: data }); + } + } else { + for(var key in context) { + if(context.hasOwnProperty(key)) { + if(data) { data.key = key; } + ret = ret + fn(context[key], {data: data}); + i++; + } + } + } + } + + if(i === 0){ + ret = inverse(this); + } + + return ret; +}); + +Handlebars.registerHelper('if', function(context, options) { + var type = toString.call(context); + if(type === functionType) { context = context.call(this); } + + if(!context || Handlebars.Utils.isEmpty(context)) { + return options.inverse(this); + } else { + return options.fn(this); + } +}); + +Handlebars.registerHelper('unless', function(context, options) { + var fn = options.fn, inverse = options.inverse; + options.fn = inverse; + options.inverse = fn; + + return Handlebars.helpers['if'].call(this, context, options); +}); + +Handlebars.registerHelper('with', function(context, options) { + return options.fn(context); +}); + +Handlebars.registerHelper('log', function(context) { + Handlebars.log(context); +}); + +}(this.Handlebars)); +; +// lib/handlebars/compiler/parser.js +/* Jison generated parser */ +var handlebars = (function(){ +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"DATA":27,"param":28,"STRING":29,"INTEGER":30,"BOOLEAN":31,"hashSegments":32,"hashSegment":33,"ID":34,"EQUALS":35,"pathSegments":36,"SEP":37,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",27:"DATA",29:"STRING",30:"INTEGER",31:"BOOLEAN",34:"ID",35:"EQUALS",37:"SEP"}, +productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[17,1],[25,2],[25,1],[28,1],[28,1],[28,1],[28,1],[28,1],[26,1],[32,2],[32,1],[33,3],[33,3],[33,3],[33,3],[33,3],[21,1],[36,3],[36,1]], +performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { + +var $0 = $$.length - 1; +switch (yystate) { +case 1: return $$[$0-1]; +break; +case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]); +break; +case 3: this.$ = new yy.ProgramNode($$[$0]); +break; +case 4: this.$ = new yy.ProgramNode([]); +break; +case 5: this.$ = [$$[$0]]; +break; +case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; +break; +case 7: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]); +break; +case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]); +break; +case 9: this.$ = $$[$0]; +break; +case 10: this.$ = $$[$0]; +break; +case 11: this.$ = new yy.ContentNode($$[$0]); +break; +case 12: this.$ = new yy.CommentNode($$[$0]); +break; +case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); +break; +case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); +break; +case 15: this.$ = $$[$0-1]; +break; +case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); +break; +case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true); +break; +case 18: this.$ = new yy.PartialNode($$[$0-1]); +break; +case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]); +break; +case 20: +break; +case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]]; +break; +case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null]; +break; +case 23: this.$ = [[$$[$0-1]], $$[$0]]; +break; +case 24: this.$ = [[$$[$0]], null]; +break; +case 25: this.$ = [[new yy.DataNode($$[$0])], null]; +break; +case 26: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; +break; +case 27: this.$ = [$$[$0]]; +break; +case 28: this.$ = $$[$0]; +break; +case 29: this.$ = new yy.StringNode($$[$0]); +break; +case 30: this.$ = new yy.IntegerNode($$[$0]); +break; +case 31: this.$ = new yy.BooleanNode($$[$0]); +break; +case 32: this.$ = new yy.DataNode($$[$0]); +break; +case 33: this.$ = new yy.HashNode($$[$0]); +break; +case 34: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; +break; +case 35: this.$ = [$$[$0]]; +break; +case 36: this.$ = [$$[$0-2], $$[$0]]; +break; +case 37: this.$ = [$$[$0-2], new yy.StringNode($$[$0])]; +break; +case 38: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])]; +break; +case 39: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])]; +break; +case 40: this.$ = [$$[$0-2], new yy.DataNode($$[$0])]; +break; +case 41: this.$ = new yy.IdNode($$[$0]); +break; +case 42: $$[$0-2].push($$[$0]); this.$ = $$[$0-2]; +break; +case 43: this.$ = [$$[$0]]; +break; +} +}, +table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,27:[1,24],34:[1,26],36:25},{17:27,21:23,27:[1,24],34:[1,26],36:25},{17:28,21:23,27:[1,24],34:[1,26],36:25},{17:29,21:23,27:[1,24],34:[1,26],36:25},{21:30,34:[1,26],36:25},{1:[2,1]},{6:31,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,32],21:23,27:[1,24],34:[1,26],36:25},{10:33,20:[1,34]},{10:35,20:[1,34]},{18:[1,36]},{18:[2,24],21:41,25:37,26:38,27:[1,45],28:39,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,25]},{18:[2,41],27:[2,41],29:[2,41],30:[2,41],31:[2,41],34:[2,41],37:[1,48]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],37:[2,43]},{18:[1,49]},{18:[1,50]},{18:[1,51]},{18:[1,52],21:53,34:[1,26],36:25},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:54,34:[1,26],36:25},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:41,26:55,27:[1,45],28:56,29:[1,42],30:[1,43],31:[1,44],32:40,33:46,34:[1,47],36:25},{18:[2,23]},{18:[2,27],27:[2,27],29:[2,27],30:[2,27],31:[2,27],34:[2,27]},{18:[2,33],33:57,34:[1,58]},{18:[2,28],27:[2,28],29:[2,28],30:[2,28],31:[2,28],34:[2,28]},{18:[2,29],27:[2,29],29:[2,29],30:[2,29],31:[2,29],34:[2,29]},{18:[2,30],27:[2,30],29:[2,30],30:[2,30],31:[2,30],34:[2,30]},{18:[2,31],27:[2,31],29:[2,31],30:[2,31],31:[2,31],34:[2,31]},{18:[2,32],27:[2,32],29:[2,32],30:[2,32],31:[2,32],34:[2,32]},{18:[2,35],34:[2,35]},{18:[2,43],27:[2,43],29:[2,43],30:[2,43],31:[2,43],34:[2,43],35:[1,59],37:[2,43]},{34:[1,60]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,61]},{18:[1,62]},{18:[2,21]},{18:[2,26],27:[2,26],29:[2,26],30:[2,26],31:[2,26],34:[2,26]},{18:[2,34],34:[2,34]},{35:[1,59]},{21:63,27:[1,67],29:[1,64],30:[1,65],31:[1,66],34:[1,26],36:25},{18:[2,42],27:[2,42],29:[2,42],30:[2,42],31:[2,42],34:[2,42],37:[2,42]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,36],34:[2,36]},{18:[2,37],34:[2,37]},{18:[2,38],34:[2,38]},{18:[2,39],34:[2,39]},{18:[2,40],34:[2,40]}], +defaultActions: {16:[2,1],24:[2,25],38:[2,23],55:[2,21]}, +parseError: function parseError(str, hash) { + throw new Error(str); +}, +parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == "undefined") + this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === "function") + this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== "number") { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + if (!recovering) { + expected = []; + for (p in table[state]) + if (this.terminals_[p] && p > 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +} +}; +/* Jison generated lexer */ +var lexer = (function(){ +var lexer = ({EOF:1, +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, +setInput:function (input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; + if (this.options.ranges) this.yylloc.range = [0,0]; + this.offset = 0; + return this; + }, +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length-len-1); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length-1); + this.matched = this.matched.substr(0, this.matched.length-1); + + if (lines.length-1) this.yylineno -= lines.length-1; + var r = this.yylloc.range; + + this.yylloc = {first_line: this.yylloc.first_line, + last_line: this.yylineno+1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, +more:function () { + this._more = true; + return this; + }, +less:function (n) { + this.unput(this.match.slice(n)); + }, +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); + }, +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c+"^"; + }, +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, + match, + tempMatch, + index, + col, + lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i=0;i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = {first_line: this.yylloc.last_line, + last_line: this.yylineno+1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); + if (this.done && this._input) this.done = false; + if (token) return token; + else return; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + {text: "", token: null, line: this.yylineno}); + } + }, +lex:function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, +begin:function begin(condition) { + this.conditionStack.push(condition); + }, +popState:function popState() { + return this.conditionStack.pop(); + }, +_currentRules:function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; + }, +topState:function () { + return this.conditionStack[this.conditionStack.length-2]; + }, +pushState:function begin(condition) { + this.begin(condition); + }}); +lexer.options = {}; +lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + +var YYSTATE=YY_START +switch($avoiding_name_collisions) { +case 0: + if(yy_.yytext.slice(-1) !== "\\") this.begin("mu"); + if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu"); + if(yy_.yytext) return 14; + +break; +case 1: return 14; +break; +case 2: + if(yy_.yytext.slice(-1) !== "\\") this.popState(); + if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1); + return 14; + +break; +case 3: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15; +break; +case 4: return 24; +break; +case 5: return 16; +break; +case 6: return 20; +break; +case 7: return 19; +break; +case 8: return 19; +break; +case 9: return 23; +break; +case 10: return 23; +break; +case 11: this.popState(); this.begin('com'); +break; +case 12: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; +break; +case 13: return 22; +break; +case 14: return 35; +break; +case 15: return 34; +break; +case 16: return 34; +break; +case 17: return 37; +break; +case 18: /*ignore whitespace*/ +break; +case 19: this.popState(); return 18; +break; +case 20: this.popState(); return 18; +break; +case 21: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29; +break; +case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 29; +break; +case 23: yy_.yytext = yy_.yytext.substr(1); return 27; +break; +case 24: return 31; +break; +case 25: return 31; +break; +case 26: return 30; +break; +case 27: return 34; +break; +case 28: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 34; +break; +case 29: return 'INVALID'; +break; +case 30: return 5; +break; +} +}; +lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; +lexer.conditions = {"mu":{"rules":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[3],"inclusive":false},"INITIAL":{"rules":[0,1,30],"inclusive":true}}; +return lexer;})() +parser.lexer = lexer; +function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})(); +if (typeof require !== 'undefined' && typeof exports !== 'undefined') { +exports.parser = handlebars; +exports.Parser = handlebars.Parser; +exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); } +exports.main = function commonjsMain(args) { + if (!args[1]) + throw new Error('Usage: '+args[0]+' FILE'); + var source, cwd; + if (typeof process !== 'undefined') { + source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8"); + } else { + source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"}); + } + return exports.parser.parse(source); +} +if (typeof module !== 'undefined' && require.main === module) { + exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args); +} +}; +; +// lib/handlebars/compiler/base.js +Handlebars.Parser = handlebars; + +Handlebars.parse = function(string) { + Handlebars.Parser.yy = Handlebars.AST; + return Handlebars.Parser.parse(string); +}; + +Handlebars.print = function(ast) { + return new Handlebars.PrintVisitor().accept(ast); +}; + +Handlebars.logger = { + DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, + + // override in the host environment + log: function(level, str) {} +}; + +Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); }; +; +// lib/handlebars/compiler/ast.js +(function() { + + Handlebars.AST = {}; + + Handlebars.AST.ProgramNode = function(statements, inverse) { + this.type = "program"; + this.statements = statements; + if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); } + }; + + Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) { + this.type = "mustache"; + this.escaped = !unescaped; + this.hash = hash; + + var id = this.id = rawParams[0]; + var params = this.params = rawParams.slice(1); + + // a mustache is an eligible helper if: + // * its id is simple (a single part, not `this` or `..`) + var eligibleHelper = this.eligibleHelper = id.isSimple; + + // a mustache is definitely a helper if: + // * it is an eligible helper, and + // * it has at least one parameter or hash segment + this.isHelper = eligibleHelper && (params.length || hash); + + // if a mustache is an eligible helper but not a definite + // helper, it is ambiguous, and will be resolved in a later + // pass or at runtime. + }; + + Handlebars.AST.PartialNode = function(id, context) { + this.type = "partial"; + + // TODO: disallow complex IDs + + this.id = id; + this.context = context; + }; + + var verifyMatch = function(open, close) { + if(open.original !== close.original) { + throw new Handlebars.Exception(open.original + " doesn't match " + close.original); + } + }; + + Handlebars.AST.BlockNode = function(mustache, program, inverse, close) { + verifyMatch(mustache.id, close); + this.type = "block"; + this.mustache = mustache; + this.program = program; + this.inverse = inverse; + + if (this.inverse && !this.program) { + this.isInverse = true; + } + }; + + Handlebars.AST.ContentNode = function(string) { + this.type = "content"; + this.string = string; + }; + + Handlebars.AST.HashNode = function(pairs) { + this.type = "hash"; + this.pairs = pairs; + }; + + Handlebars.AST.IdNode = function(parts) { + this.type = "ID"; + this.original = parts.join("."); + + var dig = [], depth = 0; + + for(var i=0,l=parts.length; i<l; i++) { + var part = parts[i]; + + if(part === "..") { depth++; } + else if(part === "." || part === "this") { this.isScoped = true; } + else { dig.push(part); } + } + + this.parts = dig; + this.string = dig.join('.'); + this.depth = depth; + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; + }; + + Handlebars.AST.DataNode = function(id) { + this.type = "DATA"; + this.id = id; + }; + + Handlebars.AST.StringNode = function(string) { + this.type = "STRING"; + this.string = string; + }; + + Handlebars.AST.IntegerNode = function(integer) { + this.type = "INTEGER"; + this.integer = integer; + }; + + Handlebars.AST.BooleanNode = function(bool) { + this.type = "BOOLEAN"; + this.bool = bool; + }; + + Handlebars.AST.CommentNode = function(comment) { + this.type = "comment"; + this.comment = comment; + }; + +})();; +// lib/handlebars/utils.js +Handlebars.Exception = function(message) { + var tmp = Error.prototype.constructor.apply(this, arguments); + + for (var p in tmp) { + if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; } + } + + this.message = tmp.message; +}; +Handlebars.Exception.prototype = new Error(); + +// Build out our basic SafeString type +Handlebars.SafeString = function(string) { + this.string = string; +}; +Handlebars.SafeString.prototype.toString = function() { + return this.string.toString(); +}; + +(function() { + var escape = { + "&": "&amp;", + "<": "&lt;", + ">": "&gt;", + '"': "&quot;", + "'": "&#x27;", + "`": "&#x60;" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + var escapeChar = function(chr) { + return escape[chr] || "&amp;"; + }; + + Handlebars.Utils = { + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (typeof value === "undefined") { + return true; + } else if (value === null) { + return true; + } else if (value === false) { + return true; + } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } + }; +})();; +// lib/handlebars/compiler/compiler.js + +/*jshint eqnull:true*/ +Handlebars.Compiler = function() {}; +Handlebars.JavaScriptCompiler = function() {}; + +(function(Compiler, JavaScriptCompiler) { + // the foundHelper register will disambiguate helper lookup from finding a + // function in a context. This is necessary for mustache compatibility, which + // requires that context functions in blocks are evaluated by blockHelperMissing, + // and then proceed as if the resulting value was provided to blockHelperMissing. + + Compiler.prototype = { + compiler: Compiler, + + disassemble: function() { + var opcodes = this.opcodes, opcode, out = [], params, param; + + for (var i=0, l=opcodes.length; i<l; i++) { + opcode = opcodes[i]; + + if (opcode.opcode === 'DECLARE') { + out.push("DECLARE " + opcode.name + "=" + opcode.value); + } else { + params = []; + for (var j=0; j<opcode.args.length; j++) { + param = opcode.args[j]; + if (typeof param === "string") { + param = "\"" + param.replace("\n", "\\n") + "\""; + } + params.push(param); + } + out.push(opcode.opcode + " " + params.join(" ")); + } + } + + return out.join("\n"); + }, + + guid: 0, + + compile: function(program, options) { + this.children = []; + this.depths = {list: []}; + this.options = options; + + // These changes will propagate to the other compiler components + var knownHelpers = this.options.knownHelpers; + this.options.knownHelpers = { + 'helperMissing': true, + 'blockHelperMissing': true, + 'each': true, + 'if': true, + 'unless': true, + 'with': true, + 'log': true + }; + if (knownHelpers) { + for (var name in knownHelpers) { + this.options.knownHelpers[name] = knownHelpers[name]; + } + } + + return this.program(program); + }, + + accept: function(node) { + return this[node.type](node); + }, + + program: function(program) { + var statements = program.statements, statement; + this.opcodes = []; + + for(var i=0, l=statements.length; i<l; i++) { + statement = statements[i]; + this[statement.type](statement); + } + this.isSimple = l === 1; + + this.depths.list = this.depths.list.sort(function(a, b) { + return a - b; + }); + + return this; + }, + + compileProgram: function(program) { + var result = new this.compiler().compile(program, this.options); + var guid = this.guid++, depth; + + this.usePartial = this.usePartial || result.usePartial; + + this.children[guid] = result; + + for(var i=0, l=result.depths.list.length; i<l; i++) { + depth = result.depths.list[i]; + + if(depth < 2) { continue; } + else { this.addDepth(depth - 1); } + } + + return guid; + }, + + block: function(block) { + var mustache = block.mustache, + program = block.program, + inverse = block.inverse; + + if (program) { + program = this.compileProgram(program); + } + + if (inverse) { + inverse = this.compileProgram(inverse); + } + + var type = this.classifyMustache(mustache); + + if (type === "helper") { + this.helperMustache(mustache, program, inverse); + } else if (type === "simple") { + this.simpleMustache(mustache); + + // now that the simple mustache is resolved, we need to + // evaluate it by executing `blockHelperMissing` + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + this.opcode('pushLiteral', '{}'); + this.opcode('blockValue'); + } else { + this.ambiguousMustache(mustache, program, inverse); + + // now that the simple mustache is resolved, we need to + // evaluate it by executing `blockHelperMissing` + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + this.opcode('pushLiteral', '{}'); + this.opcode('ambiguousBlockValue'); + } + + this.opcode('append'); + }, + + hash: function(hash) { + var pairs = hash.pairs, pair, val; + + this.opcode('push', '{}'); + + for(var i=0, l=pairs.length; i<l; i++) { + pair = pairs[i]; + val = pair[1]; + + this.accept(val); + this.opcode('assignToHash', pair[0]); + } + }, + + partial: function(partial) { + var id = partial.id; + this.usePartial = true; + + if(partial.context) { + this.ID(partial.context); + } else { + this.opcode('push', 'depth0'); + } + + this.opcode('invokePartial', id.original); + this.opcode('append'); + }, + + content: function(content) { + this.opcode('appendContent', content.string); + }, + + mustache: function(mustache) { + var options = this.options; + var type = this.classifyMustache(mustache); + + if (type === "simple") { + this.simpleMustache(mustache); + } else if (type === "helper") { + this.helperMustache(mustache); + } else { + this.ambiguousMustache(mustache); + } + + if(mustache.escaped && !options.noEscape) { + this.opcode('appendEscaped'); + } else { + this.opcode('append'); + } + }, + + ambiguousMustache: function(mustache, program, inverse) { + var id = mustache.id, name = id.parts[0]; + + this.opcode('getContext', id.depth); + + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + + this.opcode('invokeAmbiguous', name); + }, + + simpleMustache: function(mustache, program, inverse) { + var id = mustache.id; + + if (id.type === 'DATA') { + this.DATA(id); + } else if (id.parts.length) { + this.ID(id); + } else { + // Simplified ID for `this` + this.addDepth(id.depth); + this.opcode('getContext', id.depth); + this.opcode('pushContext'); + } + + this.opcode('resolvePossibleLambda'); + }, + + helperMustache: function(mustache, program, inverse) { + var params = this.setupFullMustacheParams(mustache, program, inverse), + name = mustache.id.parts[0]; + + if (this.options.knownHelpers[name]) { + this.opcode('invokeKnownHelper', params.length, name); + } else if (this.knownHelpersOnly) { + throw new Error("You specified knownHelpersOnly, but used the unknown helper " + name); + } else { + this.opcode('invokeHelper', params.length, name); + } + }, + + ID: function(id) { + this.addDepth(id.depth); + this.opcode('getContext', id.depth); + + var name = id.parts[0]; + if (!name) { + this.opcode('pushContext'); + } else { + this.opcode('lookupOnContext', id.parts[0]); + } + + for(var i=1, l=id.parts.length; i<l; i++) { + this.opcode('lookup', id.parts[i]); + } + }, + + DATA: function(data) { + this.options.data = true; + this.opcode('lookupData', data.id); + }, + + STRING: function(string) { + this.opcode('pushString', string.string); + }, + + INTEGER: function(integer) { + this.opcode('pushLiteral', integer.integer); + }, + + BOOLEAN: function(bool) { + this.opcode('pushLiteral', bool.bool); + }, + + comment: function() {}, + + // HELPERS + opcode: function(name) { + this.opcodes.push({ opcode: name, args: [].slice.call(arguments, 1) }); + }, + + declare: function(name, value) { + this.opcodes.push({ opcode: 'DECLARE', name: name, value: value }); + }, + + addDepth: function(depth) { + if(isNaN(depth)) { throw new Error("EWOT"); } + if(depth === 0) { return; } + + if(!this.depths[depth]) { + this.depths[depth] = true; + this.depths.list.push(depth); + } + }, + + classifyMustache: function(mustache) { + var isHelper = mustache.isHelper; + var isEligible = mustache.eligibleHelper; + var options = this.options; + + // if ambiguous, we can possibly resolve the ambiguity now + if (isEligible && !isHelper) { + var name = mustache.id.parts[0]; + + if (options.knownHelpers[name]) { + isHelper = true; + } else if (options.knownHelpersOnly) { + isEligible = false; + } + } + + if (isHelper) { return "helper"; } + else if (isEligible) { return "ambiguous"; } + else { return "simple"; } + }, + + pushParams: function(params) { + var i = params.length, param; + + while(i--) { + param = params[i]; + + if(this.options.stringParams) { + if(param.depth) { + this.addDepth(param.depth); + } + + this.opcode('getContext', param.depth || 0); + this.opcode('pushStringParam', param.string); + } else { + this[param.type](param); + } + } + }, + + setupMustacheParams: function(mustache) { + var params = mustache.params; + this.pushParams(params); + + if(mustache.hash) { + this.hash(mustache.hash); + } else { + this.opcode('pushLiteral', '{}'); + } + + return params; + }, + + // this will replace setupMustacheParams when we're done + setupFullMustacheParams: function(mustache, program, inverse) { + var params = mustache.params; + this.pushParams(params); + + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + + if(mustache.hash) { + this.hash(mustache.hash); + } else { + this.opcode('pushLiteral', '{}'); + } + + return params; + } + }; + + var Literal = function(value) { + this.value = value; + }; + + JavaScriptCompiler.prototype = { + // PUBLIC API: You can override these methods in a subclass to provide + // alternative compiled forms for name lookup and buffering semantics + nameLookup: function(parent, name, type) { + if (/^[0-9]+$/.test(name)) { + return parent + "[" + name + "]"; + } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) { + return parent + "." + name; + } + else { + return parent + "['" + name + "']"; + } + }, + + appendToBuffer: function(string) { + if (this.environment.isSimple) { + return "return " + string + ";"; + } else { + return "buffer += " + string + ";"; + } + }, + + initializeBuffer: function() { + return this.quotedString(""); + }, + + namespace: "Handlebars", + // END PUBLIC API + + compile: function(environment, options, context, asObject) { + this.environment = environment; + this.options = options || {}; + + Handlebars.log(Handlebars.logger.DEBUG, this.environment.disassemble() + "\n\n"); + + this.name = this.environment.name; + this.isChild = !!context; + this.context = context || { + programs: [], + aliases: { } + }; + + this.preamble(); + + this.stackSlot = 0; + this.stackVars = []; + this.registers = { list: [] }; + this.compileStack = []; + + this.compileChildren(environment, options); + + var opcodes = environment.opcodes, opcode; + + this.i = 0; + + for(l=opcodes.length; this.i<l; this.i++) { + opcode = opcodes[this.i]; + + if(opcode.opcode === 'DECLARE') { + this[opcode.name] = opcode.value; + } else { + this[opcode.opcode].apply(this, opcode.args); + } + } + + return this.createFunctionContext(asObject); + }, + + nextOpcode: function() { + var opcodes = this.environment.opcodes, opcode = opcodes[this.i + 1]; + return opcodes[this.i + 1]; + }, + + eat: function(opcode) { + this.i = this.i + 1; + }, + + preamble: function() { + var out = []; + + if (!this.isChild) { + var namespace = this.namespace; + var copies = "helpers = helpers || " + namespace + ".helpers;"; + if (this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; } + if (this.options.data) { copies = copies + " data = data || {};"; } + out.push(copies); + } else { + out.push(''); + } + + if (!this.environment.isSimple) { + out.push(", buffer = " + this.initializeBuffer()); + } else { + out.push(""); + } + + // track the last context pushed into place to allow skipping the + // getContext opcode when it would be a noop + this.lastContext = 0; + this.source = out; + }, + + createFunctionContext: function(asObject) { + var locals = this.stackVars.concat(this.registers.list); + + if(locals.length > 0) { + this.source[1] = this.source[1] + ", " + locals.join(", "); + } + + // Generate minimizer alias mappings + if (!this.isChild) { + var aliases = []; + for (var alias in this.context.aliases) { + this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; + } + } + + if (this.source[1]) { + this.source[1] = "var " + this.source[1].substring(2) + ";"; + } + + // Merge children + if (!this.isChild) { + this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; + } + + if (!this.environment.isSimple) { + this.source.push("return buffer;"); + } + + var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; + + for(var i=0, l=this.environment.depths.list.length; i<l; i++) { + params.push("depth" + this.environment.depths.list[i]); + } + + if (asObject) { + params.push(this.source.join("\n ")); + + return Function.apply(this, params); + } else { + var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + this.source.join("\n ") + '}'; + Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n"); + return functionSource; + } + }, + + // [blockValue] + // + // On stack, before: hash, inverse, program, value + // On stack, after: return value of blockHelperMissing + // + // The purpose of this opcode is to take a block of the form + // `{{#foo}}...{{/foo}}`, resolve the value of `foo`, and + // replace it on the stack with the result of properly + // invoking blockHelperMissing. + blockValue: function() { + this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing'; + + var params = ["depth0"]; + this.setupParams(0, params); + + this.replaceStack(function(current) { + params.splice(1, 0, current); + return current + " = blockHelperMissing.call(" + params.join(", ") + ")"; + }); + }, + + // [ambiguousBlockValue] + // + // On stack, before: hash, inverse, program, value + // Compiler value, before: lastHelper=value of last found helper, if any + // On stack, after, if no lastHelper: same as [blockValue] + // On stack, after, if lastHelper: value + ambiguousBlockValue: function() { + this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing'; + + var params = ["depth0"]; + this.setupParams(0, params); + + var current = this.topStack(); + params.splice(1, 0, current); + + this.source.push("if (!" + this.lastHelper + ") { " + current + " = blockHelperMissing.call(" + params.join(", ") + "); }"); + }, + + // [appendContent] + // + // On stack, before: ... + // On stack, after: ... + // + // Appends the string value of `content` to the current buffer + appendContent: function(content) { + this.source.push(this.appendToBuffer(this.quotedString(content))); + }, + + // [append] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Coerces `value` to a String and appends it to the current buffer. + // + // If `value` is truthy, or 0, it is coerced into a string and appended + // Otherwise, the empty string is appended + append: function() { + var local = this.popStack(); + this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }"); + if (this.environment.isSimple) { + this.source.push("else { " + this.appendToBuffer("''") + " }"); + } + }, + + // [appendEscaped] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Escape `value` and append it to the buffer + appendEscaped: function() { + var opcode = this.nextOpcode(), extra = ""; + this.context.aliases.escapeExpression = 'this.escapeExpression'; + + if(opcode && opcode.opcode === 'appendContent') { + extra = " + " + this.quotedString(opcode.args[0]); + this.eat(opcode); + } + + this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")" + extra)); + }, + + // [getContext] + // + // On stack, before: ... + // On stack, after: ... + // Compiler value, after: lastContext=depth + // + // Set the value of the `lastContext` compiler value to the depth + getContext: function(depth) { + if(this.lastContext !== depth) { + this.lastContext = depth; + } + }, + + // [lookupOnContext] + // + // On stack, before: ... + // On stack, after: currentContext[name], ... + // + // Looks up the value of `name` on the current context and pushes + // it onto the stack. + lookupOnContext: function(name) { + this.pushStack(this.nameLookup('depth' + this.lastContext, name, 'context')); + }, + + // [pushContext] + // + // On stack, before: ... + // On stack, after: currentContext, ... + // + // Pushes the value of the current context onto the stack. + pushContext: function() { + this.pushStackLiteral('depth' + this.lastContext); + }, + + // [resolvePossibleLambda] + // + // On stack, before: value, ... + // On stack, after: resolved value, ... + // + // If the `value` is a lambda, replace it on the stack by + // the return value of the lambda + resolvePossibleLambda: function() { + this.context.aliases.functionType = '"function"'; + + this.replaceStack(function(current) { + return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current; + }); + }, + + // [lookup] + // + // On stack, before: value, ... + // On stack, after: value[name], ... + // + // Replace the value on the stack with the result of looking + // up `name` on `value` + lookup: function(name) { + this.replaceStack(function(current) { + return current + " == null || " + current + " === false ? " + current + " : " + this.nameLookup(current, name, 'context'); + }); + }, + + // [lookupData] + // + // On stack, before: ... + // On stack, after: data[id], ... + // + // Push the result of looking up `id` on the current data + lookupData: function(id) { + this.pushStack(this.nameLookup('data', id, 'data')); + }, + + // [pushStringParam] + // + // On stack, before: ... + // On stack, after: string, currentContext, ... + // + // This opcode is designed for use in string mode, which + // provides the string value of a parameter along with its + // depth rather than resolving it immediately. + pushStringParam: function(string) { + this.pushStackLiteral('depth' + this.lastContext); + this.pushString(string); + }, + + // [pushString] + // + // On stack, before: ... + // On stack, after: quotedString(string), ... + // + // Push a quoted version of `string` onto the stack + pushString: function(string) { + this.pushStackLiteral(this.quotedString(string)); + }, + + // [push] + // + // On stack, before: ... + // On stack, after: expr, ... + // + // Push an expression onto the stack + push: function(expr) { + this.pushStack(expr); + }, + + // [pushLiteral] + // + // On stack, before: ... + // On stack, after: value, ... + // + // Pushes a value onto the stack. This operation prevents + // the compiler from creating a temporary variable to hold + // it. + pushLiteral: function(value) { + this.pushStackLiteral(value); + }, + + // [pushProgram] + // + // On stack, before: ... + // On stack, after: program(guid), ... + // + // Push a program expression onto the stack. This takes + // a compile-time guid and converts it into a runtime-accessible + // expression. + pushProgram: function(guid) { + if (guid != null) { + this.pushStackLiteral(this.programExpression(guid)); + } else { + this.pushStackLiteral(null); + } + }, + + // [invokeHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // Pops off the helper's parameters, invokes the helper, + // and pushes the helper's return value onto the stack. + // + // If the helper is not found, `helperMissing` is called. + invokeHelper: function(paramSize, name) { + this.context.aliases.helperMissing = 'helpers.helperMissing'; + + var helper = this.lastHelper = this.setupHelper(paramSize, name); + this.register('foundHelper', helper.name); + + this.pushStack("foundHelper ? foundHelper.call(" + + helper.callParams + ") " + ": helperMissing.call(" + + helper.helperMissingParams + ")"); + }, + + // [invokeKnownHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // This operation is used when the helper is known to exist, + // so a `helperMissing` fallback is not required. + invokeKnownHelper: function(paramSize, name) { + var helper = this.setupHelper(paramSize, name); + this.pushStack(helper.name + ".call(" + helper.callParams + ")"); + }, + + // [invokeAmbiguous] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of disambiguation + // + // This operation is used when an expression like `{{foo}}` + // is provided, but we don't know at compile-time whether it + // is a helper or a path. + // + // This operation emits more code than the other options, + // and can be avoided by passing the `knownHelpers` and + // `knownHelpersOnly` flags at compile-time. + invokeAmbiguous: function(name) { + this.context.aliases.functionType = '"function"'; + + this.pushStackLiteral('{}'); + var helper = this.setupHelper(0, name); + + var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper'); + this.register('foundHelper', helperName); + + var nonHelper = this.nameLookup('depth' + this.lastContext, name, 'context'); + var nextStack = this.nextStack(); + + this.source.push('if (foundHelper) { ' + nextStack + ' = foundHelper.call(' + helper.callParams + '); }'); + this.source.push('else { ' + nextStack + ' = ' + nonHelper + '; ' + nextStack + ' = typeof ' + nextStack + ' === functionType ? ' + nextStack + '.apply(depth0) : ' + nextStack + '; }'); + }, + + // [invokePartial] + // + // On stack, before: context, ... + // On stack after: result of partial invocation + // + // This operation pops off a context, invokes a partial with that context, + // and pushes the result of the invocation back. + invokePartial: function(name) { + var params = [this.nameLookup('partials', name, 'partial'), "'" + name + "'", this.popStack(), "helpers", "partials"]; + + if (this.options.data) { + params.push("data"); + } + + this.context.aliases.self = "this"; + this.pushStack("self.invokePartial(" + params.join(", ") + ");"); + }, + + // [assignToHash] + // + // On stack, before: value, hash, ... + // On stack, after: hash, ... + // + // Pops a value and hash off the stack, assigns `hash[key] = value` + // and pushes the hash back onto the stack. + assignToHash: function(key) { + var value = this.popStack(); + var hash = this.topStack(); + + this.source.push(hash + "['" + key + "'] = " + value + ";"); + }, + + // HELPERS + + compiler: JavaScriptCompiler, + + compileChildren: function(environment, options) { + var children = environment.children, child, compiler; + + for(var i=0, l=children.length; i<l; i++) { + child = children[i]; + compiler = new this.compiler(); + + this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children + var index = this.context.programs.length; + child.index = index; + child.name = 'program' + index; + this.context.programs[index] = compiler.compile(child, options, this.context); + } + }, + + programExpression: function(guid) { + this.context.aliases.self = "this"; + + if(guid == null) { + return "self.noop"; + } + + var child = this.environment.children[guid], + depths = child.depths.list, depth; + + var programParams = [child.index, child.name, "data"]; + + for(var i=0, l = depths.length; i<l; i++) { + depth = depths[i]; + + if(depth === 1) { programParams.push("depth0"); } + else { programParams.push("depth" + (depth - 1)); } + } + + if(depths.length === 0) { + return "self.program(" + programParams.join(", ") + ")"; + } else { + programParams.shift(); + return "self.programWithDepth(" + programParams.join(", ") + ")"; + } + }, + + register: function(name, val) { + this.useRegister(name); + this.source.push(name + " = " + val + ";"); + }, + + useRegister: function(name) { + if(!this.registers[name]) { + this.registers[name] = true; + this.registers.list.push(name); + } + }, + + pushStackLiteral: function(item) { + this.compileStack.push(new Literal(item)); + return item; + }, + + pushStack: function(item) { + this.source.push(this.incrStack() + " = " + item + ";"); + this.compileStack.push("stack" + this.stackSlot); + return "stack" + this.stackSlot; + }, + + replaceStack: function(callback) { + var item = callback.call(this, this.topStack()); + + this.source.push(this.topStack() + " = " + item + ";"); + return "stack" + this.stackSlot; + }, + + nextStack: function(skipCompileStack) { + var name = this.incrStack(); + this.compileStack.push("stack" + this.stackSlot); + return name; + }, + + incrStack: function() { + this.stackSlot++; + if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } + return "stack" + this.stackSlot; + }, + + popStack: function() { + var item = this.compileStack.pop(); + + if (item instanceof Literal) { + return item.value; + } else { + this.stackSlot--; + return item; + } + }, + + topStack: function() { + var item = this.compileStack[this.compileStack.length - 1]; + + if (item instanceof Literal) { + return item.value; + } else { + return item; + } + }, + + quotedString: function(str) { + return '"' + str + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + '"'; + }, + + setupHelper: function(paramSize, name) { + var params = []; + this.setupParams(paramSize, params); + var foundHelper = this.nameLookup('helpers', name, 'helper'); + + return { + params: params, + name: foundHelper, + callParams: ["depth0"].concat(params).join(", "), + helperMissingParams: ["depth0", this.quotedString(name)].concat(params).join(", ") + }; + }, + + // the params and contexts arguments are passed in arrays + // to fill in + setupParams: function(paramSize, params) { + var options = [], contexts = [], param, inverse, program; + + options.push("hash:" + this.popStack()); + + inverse = this.popStack(); + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + if (!program) { + this.context.aliases.self = "this"; + program = "self.noop"; + } + + if (!inverse) { + this.context.aliases.self = "this"; + inverse = "self.noop"; + } + + options.push("inverse:" + inverse); + options.push("fn:" + program); + } + + for(var i=0; i<paramSize; i++) { + param = this.popStack(); + params.push(param); + + if(this.options.stringParams) { + contexts.push(this.popStack()); + } + } + + if (this.options.stringParams) { + options.push("contexts:[" + contexts.join(",") + "]"); + } + + if(this.options.data) { + options.push("data:data"); + } + + params.push("{" + options.join(",") + "}"); + return params.join(", "); + } + }; + + var reservedWords = ( + "break else new var" + + " case finally return void" + + " catch for switch while" + + " continue function this with" + + " default if throw" + + " delete in try" + + " do instanceof typeof" + + " abstract enum int short" + + " boolean export interface static" + + " byte extends long super" + + " char final native synchronized" + + " class float package throws" + + " const goto private transient" + + " debugger implements protected volatile" + + " double import public let yield" + ).split(" "); + + var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; + + for(var i=0, l=reservedWords.length; i<l; i++) { + compilerWords[reservedWords[i]] = true; + } + + JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { + if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) { + return true; + } + return false; + }; + +})(Handlebars.Compiler, Handlebars.JavaScriptCompiler); + +Handlebars.precompile = function(string, options) { + options = options || {}; + + var ast = Handlebars.parse(string); + var environment = new Handlebars.Compiler().compile(ast, options); + return new Handlebars.JavaScriptCompiler().compile(environment, options); +}; + +Handlebars.compile = function(string, options) { + options = options || {}; + + var compiled; + function compile() { + var ast = Handlebars.parse(string); + var environment = new Handlebars.Compiler().compile(ast, options); + var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); + return Handlebars.template(templateSpec); + } + + // Template is only compiled on first use and cached after that point. + return function(context, options) { + if (!compiled) { + compiled = compile(); + } + return compiled.call(this, context, options); + }; +}; +; +// lib/handlebars/runtime.js +Handlebars.VM = { + template: function(templateSpec) { + // Just add water + var container = { + escapeExpression: Handlebars.Utils.escapeExpression, + invokePartial: Handlebars.VM.invokePartial, + programs: [], + program: function(i, fn, data) { + var programWrapper = this.programs[i]; + if(data) { + return Handlebars.VM.program(fn, data); + } else if(programWrapper) { + return programWrapper; + } else { + programWrapper = this.programs[i] = Handlebars.VM.program(fn); + return programWrapper; + } + }, + programWithDepth: Handlebars.VM.programWithDepth, + noop: Handlebars.VM.noop + }; + + return function(context, options) { + options = options || {}; + return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); + }; + }, + + programWithDepth: function(fn, data, $depth) { + var args = Array.prototype.slice.call(arguments, 2); + + return function(context, options) { + options = options || {}; + + return fn.apply(this, [context, options.data || data].concat(args)); + }; + }, + program: function(fn, data) { + return function(context, options) { + options = options || {}; + + return fn(context, options.data || data); + }; + }, + noop: function() { return ""; }, + invokePartial: function(partial, name, context, helpers, partials, data) { + var options = { helpers: helpers, partials: partials, data: data }; + + if(partial === undefined) { + throw new Handlebars.Exception("The partial " + name + " could not be found"); + } else if(partial instanceof Function) { + return partial(context, options); + } else if (!Handlebars.compile) { + throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode"); + } else { + partials[name] = Handlebars.compile(partial, {data: data !== undefined}); + return partials[name](context, options); + } + } +}; + +Handlebars.template = Handlebars.VM.template; +;
true
Other
emberjs
ember.js
de601dbc92008e97611424309dc6a7a5dc09feb6.json
Add title attribute binding to linkTo helper.
packages/ember-routing/lib/helpers/link_to.js
@@ -16,8 +16,9 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) { tagName: 'a', namedRoute: null, currentWhen: null, + title: null, activeClass: 'active', - attributeBindings: 'href', + attributeBindings: ['href', 'title'], classNameBindings: 'active', active: Ember.computed(function() {
true
Other
emberjs
ember.js
de601dbc92008e97611424309dc6a7a5dc09feb6.json
Add title attribute binding to linkTo helper.
packages/ember/tests/helpers/link_to_test.js
@@ -181,3 +181,14 @@ test("The {{linkTo}} helper moves into the named route with context", function() equal(Ember.$('p', '#qunit-fixture').text(), "Erik Brynroflsson", "The name is correct"); }); +test("The {{linkTo}} helper binds some anchor html tag common attributes", function() { + Router.map(function(match) { + match("/").to("home"); + }); + Ember.TEMPLATES.home = Ember.Handlebars.compile("<h3>Home</h3>{{#linkTo home id='self-link' title='title-attr'}}Self{{/linkTo}}"); + bootApplication(); + Ember.run(function() { + router.handleURL("/"); + }); + equal(Ember.$('#self-link', '#qunit-fixture').attr('title'), 'title-attr', "The self-link contains title attribute"); +});
true
Other
emberjs
ember.js
471e6f5396c3ab661ab9459b4e0ff6f935b50194.json
Fix typos in documentation guidelines
CONTRIBUTING.md
@@ -102,10 +102,10 @@ Syntax: * a = b and not a=b. * Follow the conventions you see used in the source already. -Inline Documenation Guidelines: +Inline Documentation Guidelines: All inline documentation is written using YUIDoc. Follow these rules when -updating or writing new documenation: +updating or writing new documentation: 1. All code blocks must be fenced 2. All code blocks must have a language declared
false
Other
emberjs
ember.js
d39c1e1754eb93d8ac06d9ae50e1ead66cf7d310.json
Fix Chrome (pre v25) MutationObserver Memory Leak https://github.com/tildeio/rsvp.js/pull/40 https://github.com/emberjs/ember.js/issues/1667 http://code.google.com/p/chromium/issues/detail?id=160985
packages/rsvp/lib/main.js
@@ -30,6 +30,12 @@ define("rsvp", var element = document.createElement('div'); observer.observe(element, { attributes: true }); + // Chrome Memory Leak: https://bugs.webkit.org/show_bug.cgi?id=93661 + window.addEventListener('unload', function(){ + observer.disconnect(); + observer = null; + }); + async = function(callback, binding) { queue.push([callback, binding]); element.setAttribute('drainQueue', 'drainQueue');
false
Other
emberjs
ember.js
3e033ffeb8f69e7f386afc632b107bd60b2cb1ae.json
Add test for #1669
packages/ember-old-router/tests/view_test.js
@@ -0,0 +1,27 @@ +var set = Ember.set, get = Ember.get; + +module("Ember.View - Old Router Functionality", { + setup: function() { + Ember.TEMPLATES = {}; + } +}); + +test("should load named templates from View.templates", function() { + var view; + + + view = Ember.View.create({ + templates: { + testTemplate: function() { + return "<h1 id='old-router-template-was-called'>template was called</h1>"; + } + }, + templateName: 'testTemplate' + }); + + Ember.run(function(){ + view.createElement(); + }); + + ok(view.$('#old-router-template-was-called').length, "the named template was called"); +});
false
Other
emberjs
ember.js
a5d45f66e1f71bb5eda417c688db0ea08b474903.json
Update route-recognizer with wildcard fixes
packages/ember-routing/lib/vendor/route-recognizer.js
@@ -186,9 +186,9 @@ define("route-recognizer", charSpec = child.charSpec; - if (chars = charSpec.validChars) { + if (typeof (chars = charSpec.validChars) !== 'undefined') { if (chars.indexOf(char) !== -1) { returned.push(child); } - } else if (chars = charSpec.invalidChars) { + } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') { if (chars.indexOf(char) === -1) { returned.push(child); } } }
false
Other
emberjs
ember.js
bcdb04efbbf8b69cdb89c175f2eec5e80b1e31f3.json
Fix build order for old-router
Assetfile
@@ -118,7 +118,7 @@ distros = { "runtime" => %w(ember-metal ember-runtime), "data-deps" => %w(ember-metal ember-runtime ember-states), "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph ember-handlebars ember-routing ember-application ember-states), - "old-router" => %w(ember-metal rsvp ember-runtime ember-views ember-states ember-old-router ember-viewstates metamorph ember-handlebars) + "old-router" => %w(ember-metal rsvp ember-runtime ember-views ember-states ember-viewstates metamorph ember-handlebars ember-old-router ) } output "dist"
false
Other
emberjs
ember.js
8bfaf7fba84decc5123133be7b1aaaff68a3582d.json
Fix tests with same names
packages/ember/tests/routing/basic_test.js
@@ -581,7 +581,7 @@ asyncTest("Events are triggered on the current state", function() { action.handler(event); }); -asyncTest("Events are triggered on the current state", function() { +asyncTest("Events are triggered on the current state when routes are nested", function() { Router.map(function(match) { match("/").to("root", function(match) { match("/").to("home");
false
Other
emberjs
ember.js
b2ddd989b89acfeabcf92ffb2e180c04cd8d308b.json
Fix object comparisons in IE tests
packages/ember/tests/routing/basic_test.js
@@ -553,7 +553,8 @@ asyncTest("Events are triggered on the current state", function() { events: { showStuff: function(handler, obj) { ok(handler instanceof App.HomeRoute, "the handler is an App.HomeRoute"); - deepEqual(obj, { name: "Tom Dale" }, "the context is correct"); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(Ember.copy(obj, true), { name: "Tom Dale" }, "the context is correct"); start(); } } @@ -593,7 +594,8 @@ asyncTest("Events are triggered on the current state", function() { events: { showStuff: function(handler, obj) { ok(handler instanceof App.RootRoute, "the handler is an App.HomeRoute"); - deepEqual(obj, { name: "Tom Dale" }, "the context is correct"); + // Using Ember.copy removes any private Ember vars which older IE would be confused by + deepEqual(Ember.copy(obj, true), { name: "Tom Dale" }, "the context is correct"); start(); } }
false
Other
emberjs
ember.js
dfb63a217518cc10ae48e8ce7dfd1d6f334de5d1.json
Normalize urls in tests for IE
packages/ember/tests/helpers/link_to_test.js
@@ -9,6 +9,11 @@ function bootApplication() { }); } +// IE includes the host name +function normalizeUrl(url) { + return url.replace(/https?:\/\/[^\/]+/,''); +} + module("The {{linkTo}} helper", { setup: function() { Ember.run(function() { @@ -152,7 +157,7 @@ test("The {{linkTo}} helper moves into the named route with context", function() }); equal(Ember.$('h3:contains(List)', '#qunit-fixture').length, 1, "The home template was rendered"); - equal(Ember.$('#home-link').attr('href'), '/', "The home link points back at /"); + equal(normalizeUrl(Ember.$('#home-link').attr('href')), '/', "The home link points back at /"); Ember.run(function() { Ember.$('li a:contains(Yehuda)', '#qunit-fixture').click(); @@ -164,9 +169,9 @@ test("The {{linkTo}} helper moves into the named route with context", function() Ember.run(function() { Ember.$('#home-link').click(); }); Ember.run(function() { Ember.$('#about-link').click(); }); - equal(Ember.$('li a:contains(Yehuda)').attr('href'), "/item/yehuda"); - equal(Ember.$('li a:contains(Tom)').attr('href'), "/item/tom"); - equal(Ember.$('li a:contains(Erik)').attr('href'), "/item/erik"); + equal(normalizeUrl(Ember.$('li a:contains(Yehuda)').attr('href')), "/item/yehuda"); + equal(normalizeUrl(Ember.$('li a:contains(Tom)').attr('href')), "/item/tom"); + equal(normalizeUrl(Ember.$('li a:contains(Erik)').attr('href')), "/item/erik"); Ember.run(function() { Ember.$('li a:contains(Erik)', '#qunit-fixture').click();
false
Other
emberjs
ember.js
97a86c83363786bd8191609bd9b61259cd25f0ce.json
Fix IE whitespace issues in tests
packages/ember-routing/tests/helpers/outlet_test.js
@@ -34,7 +34,8 @@ test("view should support connectOutlet for the main outlet", function() { })); }); - equal(view.$().text(), 'HIBYE'); + // Replace whitespace for older IE + equal(view.$().text().replace(/\s+/,''), 'HIBYE'); }); test("outlet should support connectOutlet in slots in prerender state", function() { @@ -68,7 +69,8 @@ test("outlet should support an optional name", function() { })); }); - equal(view.$().text(), 'HIBYE'); + // Replace whitespace for older IE + equal(view.$().text().replace(/\s+/,''), 'HIBYE'); }); test("Outlets bind to the current view, not the current concrete view", function() { @@ -118,11 +120,13 @@ test("view should support disconnectOutlet for the main outlet", function() { })); }); - equal(view.$().text(), 'HIBYE'); + // Replace whitespace for older IE + equal(view.$().text().replace(/\s+/,''), 'HIBYE'); Ember.run(function() { view.disconnectOutlet('main'); }); - equal(view.$().text(), 'HI'); + // Replace whitespace for older IE + equal(view.$().text().replace(/\s+/,''), 'HI'); });
false
Other
emberjs
ember.js
39f4e2eebb0aadf4e01cf0e85fe30356ea5169a0.json
Use Ember.Error instead of default
packages/ember-handlebars/lib/views/handlebars_bound_view.js
@@ -91,7 +91,7 @@ SimpleHandlebarsView.prototype = { case 'destroyed': break; case 'inBuffer': - throw new Error("Something you did tried to replace an {{expression}} before it was inserted into the DOM."); + throw new Ember.Error("Something you did tried to replace an {{expression}} before it was inserted into the DOM."); case 'hasElement': case 'inDOM': this.updateId = Ember.run.scheduleOnce('render', this, 'update');
true
Other
emberjs
ember.js
39f4e2eebb0aadf4e01cf0e85fe30356ea5169a0.json
Use Ember.Error instead of default
packages/ember-views/lib/views/states/in_buffer.js
@@ -22,7 +22,7 @@ Ember.merge(inBuffer, { // when a view is rendered in a buffer, rerendering it simply // replaces the existing buffer with a new one rerender: function(view) { - throw new Error("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM."); + throw new Ember.Error("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM."); }, // when a view is rendered in a buffer, appending a child
true
Other
emberjs
ember.js
17f8edf1773c363e5bdb9f3d753f8dd10191c2a4.json
bugfix Ember.Set#addEach documentation
packages/ember-runtime/lib/system/set.js
@@ -313,8 +313,10 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb This is an alias of `Ember.MutableEnumerable.addObjects()` + ```javascript var colors = new Ember.Set(); colors.addEach(["red", "green", "blue"]); // ["red", "green", "blue"] + ``` @method addEach @param {Ember.Enumerable} objects the objects to add.
false
Other
emberjs
ember.js
bf3f851ecbe3a22963975d5f3f2cb4505ed40c6f.json
Fix default `into` for nested routes By default, routes now render into their nearest parent that rendered a template. As a side-effect, application is now even less special. It just happens to be a top-level route, like `loading`.
packages/ember-application/lib/system/application.js
@@ -587,7 +587,6 @@ Ember.Application.reopenClass({ buildContainer: function(namespace) { var container = new Ember.Container(); Ember.Container.defaultContainer = container; - var ApplicationView = Ember.View.extend(); container.set = Ember.set; container.resolve = resolveFor(namespace); @@ -602,14 +601,6 @@ Ember.Application.reopenClass({ container.typeInjection('route', 'router', 'router:main'); - // Register a fallback application view. App.ApplicationView will - // take precedence. - container.register('view', 'application', ApplicationView); - if (Ember.Handlebars) { - var template = Ember.Handlebars.compile("{{outlet}}"); - container.register('template', 'application', template); - } - return container; } });
true
Other
emberjs
ember.js
bf3f851ecbe3a22963975d5f3f2cb4505ed40c6f.json
Fix default `into` for nested routes By default, routes now render into their nearest parent that rendered a template. As a side-effect, application is now even less special. It just happens to be a top-level route, like `loading`.
packages/ember-routing/lib/system/route.js
@@ -4,6 +4,10 @@ var get = Ember.get, set = Ember.set, Ember.Route = Ember.Object.extend({ + exit: function() { + teardownView(this); + }, + /** Transition into another route. Optionally supply a model for the route in question. The model will be serialized into the URL @@ -304,20 +308,42 @@ Ember.Route = Ember.Object.extend({ if (!view && !template) { return; } + this.lastRenderedTemplate = name; + options = normalizeOptions(this, name, template, options); view = setupView(view, container, options); - if (name === 'application') { - appendApplicationView(this, view); - } else { - appendView(this, view, options); - } + appendView(this, view, options); } }); +function parentRoute(route) { + var handlerInfos = route.router.router.currentHandlerInfos; + + var parent, current; + + for (var i=0, l=handlerInfos.length; i<l; i++) { + current = handlerInfos[i].handler; + if (current === route) { return parent; } + parent = current; + } +} + +function parentTemplate(route) { + var parent = parentRoute(route), template; + + if (!parent) { return; } + + if (template = parent.lastRenderedTemplate) { + return template; + } else { + return parentTemplate(parent); + } +} + function normalizeOptions(route, name, template, options) { options = options || {}; - options.into = options.into || 'application'; + options.into = options.into || parentTemplate(route); options.outlet = options.outlet || 'main'; options.name = name; options.template = template; @@ -334,9 +360,9 @@ function normalizeOptions(route, name, template, options) { } function setupView(view, container, options) { - var containerView; + var defaultView = options.into ? 'view:default' : 'view:toplevel'; - view = view || container.lookup('view:default'); + view = view || container.lookup(defaultView); set(view, 'template', options.template); set(view, 'viewName', options.name); @@ -345,13 +371,30 @@ function setupView(view, container, options) { return view; } -function appendApplicationView(route, view) { - var rootElement = get(route, 'router.namespace.rootElement'); - route.router._connectActiveView('application', view); - view.appendTo(rootElement); +function appendView(route, view, options) { + if (options.into) { + var parentView = route.router._lookupActiveView(options.into); + route.teardownView = teardownOutlet(parentView, options.outlet); + parentView.connectOutlet(options.outlet, view); + } else { + var rootElement = get(route, 'router.namespace.rootElement'); + route.router._connectActiveView(options.name, view); + route.teardownView = teardownTopLevel(view); + view.appendTo(rootElement); + } } -function appendView(route, view, options) { - var parentView = route.router._lookupActiveView(options.into); - parentView.connectOutlet(options.outlet, view); +function teardownTopLevel(view) { + return function() { view.remove(); }; +} + +function teardownOutlet(parentView, outlet) { + return function() { parentView.disconnectOutlet(outlet); }; +} + +function teardownView(route) { + if (route.teardownView) { route.teardownView(); } + + delete route.teardownView; + delete route.lastRenderedTemplate; }
true
Other
emberjs
ember.js
bf3f851ecbe3a22963975d5f3f2cb4505ed40c6f.json
Fix default `into` for nested routes By default, routes now render into their nearest parent that rendered a template. As a side-effect, application is now even less special. It just happens to be a top-level route, like `loading`.
packages/ember-routing/lib/system/router.js
@@ -49,6 +49,7 @@ Ember.Router = Ember.Object.extend({ }; container.register('view', 'default', DefaultView); + container.register('view', 'toplevel', Ember.View.extend()); router.handleURL(location.getURL()); location.onUpdateURL(function(url) {
true
Other
emberjs
ember.js
bf3f851ecbe3a22963975d5f3f2cb4505ed40c6f.json
Fix default `into` for nested routes By default, routes now render into their nearest parent that rendered a template. As a side-effect, application is now even less special. It just happens to be a top-level route, like `loading`.
packages/ember/tests/routing/basic_test.js
@@ -9,6 +9,10 @@ function bootApplication() { }); } +function compile(string) { + return Ember.Handlebars.compile(string); +} + module("Basic Routing", { setup: function() { Ember.run(function() { @@ -22,8 +26,9 @@ module("Basic Routing", { App.LoadingRoute = Ember.Route.extend({ }); - Ember.TEMPLATES.home = Ember.Handlebars.compile("<h3>Hours</h3>"); - Ember.TEMPLATES.homepage = Ember.Handlebars.compile("<h3>Megatroll</h3><p>{{home}}</p>"); + Ember.TEMPLATES.application = compile("{{outlet}}"); + Ember.TEMPLATES.home = compile("<h3>Hours</h3>"); + Ember.TEMPLATES.homepage = compile("<h3>Megatroll</h3><p>{{home}}</p>"); Router = Ember.Router.extend({ location: 'none' @@ -719,4 +724,29 @@ test("A redirection hook is provided", function() { equal(Ember.$("h3:contains(Hours)", "#qunit-fixture").length, 1, "The home template was rendered"); }); +test("Child routes render into their parent route's template by default", function() { + Ember.TEMPLATES.index = compile("<div>Index</div>"); + Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>"); + Ember.TEMPLATES.top = compile("<div class='middle'>{{outlet}}</div>"); + Ember.TEMPLATES.middle = compile("<div class='bottom'>{{outlet}}</div>"); + Ember.TEMPLATES.bottom = compile("<p>Bottom!</p>"); + + Router.map(function(match) { + match("/").to('index'); + match("/top").to("top", function(match) { + match("/middle").to("middle", function(match) { + match("/bottom").to("bottom"); + }); + }); + }); + + bootApplication(); + + Ember.run(function() { + router.handleURL("/top/middle/bottom"); + }); + + equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "Bottom!", "The templates were rendered into their appropriate parents"); +}); + // TODO: Parent context change
true
Other
emberjs
ember.js
807e23fb2febf5a8857303a0dec1f5f644707264.json
Add concatenatedProperties documentation
packages/ember-runtime/lib/system/core_object.js
@@ -163,6 +163,63 @@ CoreObject.PrototypeMixin = Mixin.create({ init: function() {}, + /** + Defines the properties that will be concatenated from the superclass + (instead of overridden). + + By default, when you extend an Ember class a property defined in + the subclass overrides a property with the same name that is defined + in the superclass. However, there are some cases where it is preferable + to build up a property's value by combining the superclass' property + value with the subclass' value. An example of this in use within Ember + is the `classNames` property of `Ember.View`. + + Here is some sample code showing the difference between a concatenated + property and a normal one: + + ```javascript + App.BarView = Ember.View.extend({ + someNonConcatenatedProperty: ['bar'], + classNames: ['bar'] + }); + + App.FooBarView = App.BarView.extend({ + someNonConcatenatedProperty: ['foo'], + classNames: ['foo'], + }); + + var fooBarView = App.FooBarView.create(); + fooBarView.get('someNonConcatenatedProperty'); // ['foo'] + fooBarView.get('classNames'); // ['ember-view', 'bar', 'foo'] + ``` + + This behavior extends to object creation as well. Continuing the + above example: + + ```javascript + var view = App.FooBarView.create({ + someNonConcatenatedProperty: ['baz'], + classNames: ['baz'] + }) + view.get('someNonConcatenatedProperty'); // ['baz'] + view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz'] + ``` + + Using the `concatenatedProperties` property, we can tell to Ember that mix + the content of the properties. + + In `Ember.View` the `classNameBindings` and `attributeBindings` properties + are also concatenated, in addition to `classNames`. + + This feature is available for you to use throughout the Ember object model, + although typical app developers are likely to use it infrequently. + + @property concatenatedProperties + @type Array + @default null + */ + concatenatedProperties: null, + /** @property isDestroyed @default false
false
Other
emberjs
ember.js
179744aca0557c53e4c38fd5e6d8dc7f38a2348a.json
Fix pre-registered injections Pre-registered injections are passed to the factory's `create`, so they are available in the init method of the class
packages/container/lib/main.js
@@ -1,3 +1,5 @@ +require('ember-runtime'); + var get = Ember.get, set = Ember.set; function Container() { @@ -74,16 +76,20 @@ function isSingleton(container, fullName) { return singleton !== false; } -function applyInjections(container, value, injections) { - if (!injections) { return; } +function buildInjections(container, injections) { + var hash = {}; + + if (!injections) { return hash; } var injection, lookup; for (var i=0, l=injections.length; i<l; i++) { injection = injections[i]; lookup = container.lookup(injection.fullName); - container.set(value, injection.property, lookup); + hash[injection.property] = lookup; } + + return hash; } function option(container, fullName, optionName) { @@ -113,13 +119,14 @@ function instantiate(container, fullName) { } if (factory) { - value = factory.create({ container: container }); - var injections = []; injections = injections.concat(container.typeInjections[type] || []); injections = injections.concat(container.injections[fullName] || []); - applyInjections(container, value, injections); + var hash = buildInjections(container, injections); + hash.container = container; + + value = factory.create(hash); return value; }
true
Other
emberjs
ember.js
179744aca0557c53e4c38fd5e6d8dc7f38a2348a.json
Fix pre-registered injections Pre-registered injections are passed to the factory's `create`, so they are available in the init method of the class
packages/container/tests/container_test.js
@@ -1,18 +1,19 @@ -var get = Ember.get; +var get = Ember.get, setProperties = Ember.setProperties, passedOptions; module("Container"); function factory() { - var Klass = function(container) { - this.container = container; + var Klass = function(options) { + setProperties(this, options); }; Klass.prototype.destroy = function() { this.isDestroyed = true; }; Klass.create = function(options) { - return new Klass(options.container); + passedOptions = options; + return new Klass(options); }; return Klass; @@ -71,7 +72,10 @@ test("An individual factory with a registered injection receives the injection", var postController = container.lookup('controller:post'); var store = container.lookup('store:main'); - equal(postController.store, store); + deepEqual(passedOptions, { + store: store, + container: container + }); }); test("A factory with both type and individual injections", function() {
true
Other
emberjs
ember.js
9f8959d4607ba675dec5985412a874aa488d9e58.json
Make promise usage nicer without mixing
packages/ember-runtime/lib/mixins/deferred.js
@@ -17,8 +17,7 @@ var get = Ember.get, @namespace Ember @extends Ember.Mixin */ -Ember.Deferred = Ember.Mixin.create({ - +Ember.DeferredMixin = Ember.Mixin.create({ /** Add handlers to be called when the Deferred object is resolved or rejected. @@ -27,7 +26,8 @@ Ember.Deferred = Ember.Mixin.create({ @param {Function} failCallback a callback function to be called when failed */ then: function(doneCallback, failCallback) { - return get(this, 'promise').then(doneCallback, failCallback); + var promise = get(this, 'promise'); + promise.then.apply(promise, arguments); }, /** @@ -52,3 +52,4 @@ Ember.Deferred = Ember.Mixin.create({ return new RSVP.Promise(); }) }); +
true
Other
emberjs
ember.js
9f8959d4607ba675dec5985412a874aa488d9e58.json
Make promise usage nicer without mixing
packages/ember-runtime/lib/system.js
@@ -10,5 +10,6 @@ require('ember-runtime/system/object'); require('ember-runtime/system/set'); require('ember-runtime/system/string'); require('ember-runtime/system/promise_chain'); +require('ember-runtime/system/deferred'); require('ember-runtime/system/lazy_load');
true
Other
emberjs
ember.js
9f8959d4607ba675dec5985412a874aa488d9e58.json
Make promise usage nicer without mixing
packages/ember-runtime/lib/system/deferred.js
@@ -0,0 +1,18 @@ +require("ember-runtime/mixins/deferred"); +require("ember-runtime/system/object"); + +var DeferredMixin = Ember.DeferredMixin, // mixins/deferred + EmberObject = Ember.Object, // system/object + get = Ember.get; + +var Deferred = Ember.Object.extend(DeferredMixin); + +Deferred.reopenClass({ + promise: function(callback, binding) { + var deferred = Deferred.create(); + callback.call(binding, deferred); + return get(deferred, 'promise'); + } +}); + +Ember.Deferred = Deferred;
true