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
83209e5d909152cd13649b77b4b769d84445e1bc.json
Move argument special casing to the helpers. Paves the way for Handlbars compat version of `registerHelper` and `makeBoundHelper`. Also, cleans up troubling bits of `streamifyArgs`.
packages/ember-htmlbars/lib/hooks.js
@@ -2,27 +2,15 @@ import Ember from "ember-metal/core"; import { lookupHelper } from "ember-htmlbars/system/lookup-helper"; import { sanitizeOptionsForHelper } from "ember-htmlbars/system/sanitize-for-helper"; -function streamifyArgs(view, params, hash, options, env) { - if (params.length === 3 && params[1] === "as") { - params.splice(0, 3, { - from: params[0], - to: params[2], - stream: view.getStream(params[0]) - }); - options.types.splice(0, 3, 'keyword'); - } else if (params.length === 3 && params[1] === "in") { - params.splice(0, 3, { - from: params[2], - to: params[0], - stream: view.getStream(params[2]) - }); - options.types.splice(0, 3, 'keyword'); - } else { - // Convert ID params to streams - for (var i = 0, l = params.length; i < l; i++) { - if (options.types[i] === 'id') { - params[i] = view.getStream(params[i]); - } +function streamifyArgs(view, params, hash, options, env, helper) { + if (helper._preprocessArguments) { + helper._preprocessArguments(view, params, hash, options, env); + } + + // Convert ID params to streams + for (var i = 0, l = params.length; i < l; i++) { + if (options.types[i] === 'id') { + params[i] = view.getStream(params[i]); } } @@ -46,7 +34,7 @@ export function content(morph, path, view, params, hash, options, env) { options.types = ['id']; } - streamifyArgs(view, params, hash, options, env); + streamifyArgs(view, params, hash, options, env, helper); sanitizeOptionsForHelper(options); return helper.call(view, params, hash, options, env); } @@ -57,7 +45,7 @@ export function component(morph, tagName, view, hash, options, env) { Ember.assert('You specified `' + tagName + '` in your template, but a component for `' + tagName + '` could not be found.', !!helper); - streamifyArgs(view, params, hash, options, env); + streamifyArgs(view, params, hash, options, env, helper); sanitizeOptionsForHelper(options); return helper.call(view, params, hash, options, env); } @@ -66,7 +54,7 @@ export function element(element, path, view, params, hash, options, env) { //jsh var helper = lookupHelper(path, view, env); if (helper) { - streamifyArgs(view, params, hash, options, env); + streamifyArgs(view, params, hash, options, env, helper); sanitizeOptionsForHelper(options); return helper.call(view, params, hash, options, env); } else { @@ -78,7 +66,7 @@ export function subexpr(path, view, params, hash, options, env) { var helper = lookupHelper(path, view, env); if (helper) { - streamifyArgs(view, params, hash, options, env); + streamifyArgs(view, params, hash, options, env, helper); sanitizeOptionsForHelper(options); return helper.call(view, params, hash, options, env); } else {
true
Other
emberjs
ember.js
f07c5e9ba92592b6207eb1486d3d5d9137f94b52.json
Update htmlbars version. Allows components to have dashes in hash parameters (specifically fixes `current-when` for the `{{link-to}}` helper).
package.json
@@ -42,7 +42,7 @@ "git-repo-version": "0.0.1", "glob": "~3.2.8", "handlebars": "^2.0", - "htmlbars": "0.1.3", + "htmlbars": "0.1.4", "ncp": "~0.5.1", "rimraf": "~2.2.8", "rsvp": "~3.0.6"
false
Other
emberjs
ember.js
18e41644485785ef05b953149e28ba9db1cfa526.json
Implement action helper for HTMLBars This commit also raises an assertion for un-quoted actions. These are long deprecated, and impossible to support with the current or planned streams implementation.
packages/ember-routing-handlebars/lib/helpers/action.js
@@ -108,15 +108,11 @@ ActionHelper.registerAction = function(actionNameOrStream, options, allowedKeys) if (actionNameOrStream.isStream) { actionName = actionNameOrStream.value(); - if (typeof actionName === 'undefined' || typeof actionName === 'function') { - actionName = actionNameOrStream._originalPath; - Ember.deprecate("You specified a quoteless path to the {{action}} helper '" + - actionName + "' which did not resolve to an actionName." + - " Perhaps you meant to use a quoted actionName? (e.g. {{action '" + actionName + "'}})."); - } - } - - if (!actionName) { + Ember.assert("You specified a quoteless path to the {{action}} helper " + + "which did not resolve to an action name (a string). " + + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", + typeof actionName === 'string'); + } else { actionName = actionNameOrStream; }
true
Other
emberjs
ember.js
18e41644485785ef05b953149e28ba9db1cfa526.json
Implement action helper for HTMLBars This commit also raises an assertion for un-quoted actions. These are long deprecated, and impossible to support with the current or planned streams implementation.
packages/ember-routing-htmlbars/lib/helpers/action.js
@@ -0,0 +1,321 @@ +/** +@module ember +@submodule ember-routing-htmlbars +*/ + +import Ember from "ember-metal/core"; // Handlebars, uuid, FEATURES, assert, deprecate +import { uuid } from "ember-metal/utils"; +import run from "ember-metal/run_loop"; +import { readUnwrappedModel } from "ember-views/streams/read"; +import { isSimpleClick } from "ember-views/system/utils"; +import ActionManager from "ember-views/system/action_manager"; +import { indexOf } from "ember-metal/array"; + +function actionArgs(parameters, actionName) { + var ret, i, l; + + if (actionName === undefined) { + ret = new Array(parameters.length); + for (i=0, l=parameters.length;i<l;i++) { + ret[i] = readUnwrappedModel(parameters[i]); + } + } else { + ret = new Array(parameters.length + 1); + ret[0] = actionName; + for (i=0, l=parameters.length;i<l; i++) { + ret[i + 1] = readUnwrappedModel(parameters[i]); + } + } + + return ret; +} + +var ActionHelper = {}; + +// registeredActions is re-exported for compatibility with older plugins +// that were using this undocumented API. +ActionHelper.registeredActions = ActionManager.registeredActions; + +export { ActionHelper }; + +var keys = ["alt", "shift", "meta", "ctrl"]; + +var POINTER_EVENT_TYPE_REGEX = /^click|mouse|touch/; + +var isAllowedEvent = function(event, allowedKeys) { + if (typeof allowedKeys === "undefined") { + if (POINTER_EVENT_TYPE_REGEX.test(event.type)) { + return isSimpleClick(event); + } else { + allowedKeys = ''; + } + } + + if (allowedKeys.indexOf("any") >= 0) { + return true; + } + + for (var i=0, l=keys.length;i<l;i++) { + if (event[keys[i] + "Key"] && allowedKeys.indexOf(keys[i]) === -1) { + return false; + } + } + + return true; +}; + +var keyEvents = ['keyUp', 'keyPress', 'keyDown']; + +function ignoreKeyEvent(eventName, event, keyCode) { + var any = 'any'; + keyCode = keyCode || any; + return indexOf.call(keyEvents, eventName) !== -1 && keyCode !== any && keyCode !== event.which.toString(); +} + +ActionHelper.registerAction = function(actionNameOrStream, options, allowedKeys) { + var actionId = uuid(); + var eventName = options.eventName; + var parameters = options.parameters; + + ActionManager.registeredActions[actionId] = { + eventName: eventName, + handler: function handleRegisteredAction(event) { + if (!isAllowedEvent(event, allowedKeys)) { return true; } + + if (options.preventDefault !== false) { + event.preventDefault(); + } + + if (options.bubbles === false) { + event.stopPropagation(); + } + + var target = options.target.value(); + + if (Ember.FEATURES.isEnabled("ember-routing-handlebars-action-with-key-code")) { + if (ignoreKeyEvent(eventName, event, options.withKeyCode)) { + return; + } + } + + var actionName; + + if (actionNameOrStream.isStream) { + actionName = actionNameOrStream.value(); + + Ember.assert("You specified a quoteless path to the {{action}} helper " + + "which did not resolve to an action name (a string). " + + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", + typeof actionName === 'string'); + } else { + actionName = actionNameOrStream; + } + + run(function runRegisteredAction() { + if (target.send) { + target.send.apply(target, actionArgs(parameters, actionName)); + } else { + Ember.assert("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === 'function'); + target[actionName].apply(target, actionArgs(parameters)); + } + }); + } + }; + + options.view.on('willClearRender', function() { + delete ActionManager.registeredActions[actionId]; + }); + + return actionId; +}; + +/** + The `{{action}}` helper provides a useful shortcut for registering an HTML + element within a template for a single DOM event and forwarding that + interaction to the template's controller or specified `target` option. + + If the controller does not implement the specified action, the event is sent + to the current route, and it bubbles up the route hierarchy from there. + + For more advanced event handling see [Ember.Component](/api/classes/Ember.Component.html) + + + ### Use + Given the following application Handlebars template on the page + + ```handlebars + <div {{action 'anActionName'}}> + click me + </div> + ``` + + And application code + + ```javascript + App.ApplicationController = Ember.Controller.extend({ + actions: { + anActionName: function() { + } + } + }); + ``` + + Will result in the following rendered HTML + + ```html + <div class="ember-view"> + <div data-ember-action="1"> + click me + </div> + </div> + ``` + + Clicking "click me" will trigger the `anActionName` action of the + `App.ApplicationController`. In this case, no additional parameters will be passed. + + If you provide additional parameters to the helper: + + ```handlebars + <button {{action 'edit' post}}>Edit</button> + ``` + + Those parameters will be passed along as arguments to the JavaScript + function implementing the action. + + ### Event Propagation + + Events triggered through the action helper will automatically have + `.preventDefault()` called on them. You do not need to do so in your event + handlers. If you need to allow event propagation (to handle file inputs for + example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + + ```handlebars + <div {{action "sayHello" preventDefault=false}}> + <input type="file" /> + <input type="checkbox" /> + </div> + ``` + + To disable bubbling, pass `bubbles=false` to the helper: + + ```handlebars + <button {{action 'edit' post bubbles=false}}>Edit</button> + ``` + + If you need the default handler to trigger you should either register your + own event handler, or use event methods on your view class. See [Ember.View](/api/classes/Ember.View.html) + 'Responding to Browser Events' for more information. + + ### Specifying DOM event type + + By default the `{{action}}` helper registers for DOM `click` events. You can + supply an `on` option to the helper to specify a different DOM event name: + + ```handlebars + <div {{action "anActionName" on="doubleClick"}}> + click me + </div> + ``` + + See `Ember.View` 'Responding to Browser Events' for a list of + acceptable DOM event names. + + ### Specifying whitelisted modifier keys + + By default the `{{action}}` helper will ignore click event with pressed modifier + keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + + ```handlebars + <div {{action "anActionName" allowedKeys="alt"}}> + click me + </div> + ``` + + This way the `{{action}}` will fire when clicking with the alt key pressed down. + + Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + + ```handlebars + <div {{action "anActionName" allowedKeys="any"}}> + click me with any key pressed + </div> + ``` + + ### Specifying a Target + + There are several possible target objects for `{{action}}` helpers: + + In a typical Ember application, where templates are managed through use of the + `{{outlet}}` helper, actions will bubble to the current controller, then + to the current route, and then up the route hierarchy. + + Alternatively, a `target` option can be provided to the helper to change + which object will receive the method call. This option must be a path + to an object, accessible in the current context: + + ```handlebars + {{! the application template }} + <div {{action "anActionName" target=view}}> + click me + </div> + ``` + + ```javascript + App.ApplicationView = Ember.View.extend({ + actions: { + anActionName: function(){} + } + }); + + ``` + + ### Additional Parameters + + You may specify additional parameters to the `{{action}}` helper. These + parameters are passed along as the arguments to the JavaScript function + implementing the action. + + ```handlebars + {{#each person in people}} + <div {{action "edit" person}}> + click me + </div> + {{/each}} + ``` + + Clicking "click me" will trigger the `edit` method on the current controller + with the value of `person` as a parameter. + + @method action + @for Ember.Handlebars.helpers + @param {String} actionName + @param {Object} [context]* + @param {Hash} options +*/ +export function actionHelper(params, hash, options, env) { + + var target; + if (!hash.target) { + target = this.getStream('controller'); + } else if (hash.target.isStream) { + target = hash.target; + } else { + target = this.getStream(hash.target); + } + + // Ember.assert("You specified a quoteless path to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", !params[0].isStream); + // Ember.deprecate("You specified a quoteless path to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}}).", params[0].isStream); + + var actionOptions = { + eventName: hash.on || "click", + parameters: params.slice(1), + view: this, + bubbles: hash.bubbles, + preventDefault: hash.preventDefault, + target: target, + withKeyCode: hash.withKeyCode + }; + + var actionId = ActionHelper.registerAction(params[0], actionOptions, hash.allowedKeys); + env.dom.setAttribute(options.element, 'data-ember-action', actionId); +}
true
Other
emberjs
ember.js
18e41644485785ef05b953149e28ba9db1cfa526.json
Implement action helper for HTMLBars This commit also raises an assertion for un-quoted actions. These are long deprecated, and impossible to support with the current or planned streams implementation.
packages/ember-routing-htmlbars/lib/main.js
@@ -15,9 +15,11 @@ import { linkToHelper, deprecatedLinkToHelper } from "ember-routing-htmlbars/helpers/link-to"; +import { actionHelper } from "ember-routing-htmlbars/helpers/action"; registerHelper('outlet', outletHelper); registerHelper('link-to', linkToHelper); registerHelper('linkTo', deprecatedLinkToHelper); +registerHelper('action', actionHelper); export default Ember;
true
Other
emberjs
ember.js
18e41644485785ef05b953149e28ba9db1cfa526.json
Implement action helper for HTMLBars This commit also raises an assertion for un-quoted actions. These are long deprecated, and impossible to support with the current or planned streams implementation.
packages/ember-routing-htmlbars/tests/helpers/action_test.js
@@ -11,26 +11,54 @@ import EmberObjectController from "ember-runtime/controllers/object_controller"; import EmberArrayController from "ember-runtime/controllers/array_controller"; import EmberHandlebars from "ember-handlebars"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; import EmberView from "ember-views/views/view"; import EmberComponent from "ember-views/views/component"; import jQuery from "ember-views/system/jquery"; import { - ActionHelper, - actionHelper + registerHelper as htmlbarsRegisterHelper, + default as htmlbarsHelpers +} from "ember-htmlbars/helpers"; + +import { + ActionHelper as HandlebarsActionHelper, + actionHelper as handlebarsActionHelper } from "ember-routing-handlebars/helpers/action"; +import { + ActionHelper as HTMLBarsActionHelper, + actionHelper as htmlbarsActionHelper +} from "ember-routing-htmlbars/helpers/action"; + +var compile, helpers, registerHelper, ActionHelper, actionHelper; +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + helpers = htmlbarsHelpers; + compile = htmlbarsCompile; + registerHelper = htmlbarsRegisterHelper; + actionHelper = htmlbarsActionHelper; + ActionHelper = HTMLBarsActionHelper; +} else { + helpers = EmberHandlebars.helpers; + compile = EmberHandlebars.compile; + registerHelper = function(name, fn) { + return EmberHandlebars.registerHelper(name, fn); + }; + actionHelper = handlebarsActionHelper; + ActionHelper = HandlebarsActionHelper; +} + var dispatcher, view, originalActionHelper; var originalRegisterAction = ActionHelper.registerAction; var appendView = function() { run(function() { view.appendTo('#qunit-fixture'); }); }; -QUnit.module("Ember.Handlebars - action helper", { +QUnit.module("ember-routing-htmlbars: action helper", { setup: function() { - originalActionHelper = EmberHandlebars.helpers['action']; - EmberHandlebars.registerHelper('action', actionHelper); + originalActionHelper = helpers['action']; + registerHelper('action', actionHelper); dispatcher = EventDispatcher.create(); dispatcher.setup(); @@ -42,14 +70,14 @@ QUnit.module("Ember.Handlebars - action helper", { if (view) { view.destroy(); } }); - delete EmberHandlebars.helpers['action']; - EmberHandlebars.helpers['action'] = originalActionHelper; + delete helpers['action']; + helpers['action'] = originalActionHelper; } }); test("should output a data attribute with a guid", function() { view = EmberView.create({ - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>edit</a>') + template: compile('<a href="#" {{action "edit"}}>edit</a>') }); appendView(); @@ -65,7 +93,7 @@ test("should by default register a click event", function() { }; view = EmberView.create({ - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>edit</a>') + template: compile('<a href="#" {{action "edit"}}>edit</a>') }); appendView(); @@ -83,7 +111,7 @@ test("should allow alternative events to be handled", function() { }; view = EmberView.create({ - template: EmberHandlebars.compile('<a href="#" {{action "edit" on="mouseUp"}}>edit</a>') + template: compile('<a href="#" {{action "edit" on="mouseUp"}}>edit</a>') }); appendView(); @@ -103,7 +131,7 @@ test("should by default target the view's controller", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>edit</a>') + template: compile('<a href="#" {{action "edit"}}>edit</a>') }); appendView(); @@ -120,7 +148,7 @@ test("Inside a yield, the target points at the original target", function() { boundText: "inner", truthy: true, obj: {}, - layout: EmberHandlebars.compile("<div>{{boundText}}</div><div>{{#if truthy}}{{yield}}{{/if}}</div>") + layout: compile("<div>{{boundText}}</div><div>{{#if truthy}}{{yield}}{{/if}}</div>") }); view = EmberView.create({ @@ -132,7 +160,7 @@ test("Inside a yield, the target points at the original target", function() { }, component: component }, - template: EmberHandlebars.compile('{{#if truthy}}{{#view component}}{{#if truthy}}<div {{action "wat"}} class="wat">{{boundText}}</div>{{/if}}{{/view}}{{/if}}') + template: compile('{{#if truthy}}{{#view component}}{{#if truthy}}<div {{action "wat"}} class="wat">{{boundText}}</div>{{/if}}{{/view}}{{/if}}') }); appendView(); @@ -144,6 +172,7 @@ test("Inside a yield, the target points at the original target", function() { equal(watted, true, "The action was called on the right context"); }); +if (!Ember.FEATURES.isEnabled('ember-htmlbars')) { test("should target the current controller inside an {{each}} loop [DEPRECATED]", function() { var registeredTarget; @@ -166,7 +195,7 @@ test("should target the current controller inside an {{each}} loop [DEPRECATED]" view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('{{#each controller}}{{action "editTodo"}}{{/each}}') + template: compile('{{#each controller}}{{action "editTodo"}}{{/each}}') }); expectDeprecation(function() { @@ -177,6 +206,7 @@ test("should target the current controller inside an {{each}} loop [DEPRECATED]" ActionHelper.registerAction = originalRegisterAction; }); +} test("should target the with-controller inside an {{#with controller='person'}} [DEPRECATED]", function() { var registeredTarget; @@ -193,7 +223,7 @@ test("should target the with-controller inside an {{#with controller='person'}} view = EmberView.create({ container: container, - template: EmberHandlebars.compile('{{#with view.person controller="person"}}{{action "editTodo"}}{{/with}}'), + template: compile('{{#with view.person controller="person"}}<div {{action "editTodo"}}></div>{{/with}}'), person: EmberObject.create(), controller: parentController }); @@ -233,7 +263,7 @@ test("should target the with-controller inside an {{each}} in a {{#with controll view = EmberView.create({ container: container, - template: EmberHandlebars.compile('{{#with people controller="people"}}{{#each}}<a href="#" {{action name}}>{{name}}</a>{{/each}}{{/with}}'), + template: compile('{{#with people controller="people"}}{{#each}}<a href="#" {{action name}}>{{name}}</a>{{/each}}{{/with}}'), controller: parentController }); @@ -257,7 +287,7 @@ test("should allow a target to be specified", function() { view = EmberView.create({ controller: {}, - template: EmberHandlebars.compile('<a href="#" {{action "edit" target="view.anotherTarget"}}>edit</a>'), + template: compile('<a href="#" {{action "edit" target=view.anotherTarget}}>edit</a>'), anotherTarget: anotherTarget }); @@ -292,7 +322,7 @@ test("should lazily evaluate the target", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit" target="theTarget"}}>edit</a>') + template: compile('<a href="#" {{action "edit" target=theTarget}}>edit</a>') }); appendView(); @@ -324,7 +354,7 @@ test("should register an event handler", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>click me</a>') + template: compile('<a href="#" {{action "edit"}}>click me</a>') }); appendView(); @@ -351,7 +381,7 @@ test("handles whitelisted modifier keys", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit" allowedKeys="alt"}}>click me</a> <div {{action "shortcut" allowedKeys="any"}}>click me too</div>') + template: compile('<a href="#" {{action "edit" allowedKeys="alt"}}>click me</a> <div {{action "shortcut" allowedKeys="any"}}>click me too</div>') }); appendView(); @@ -387,7 +417,7 @@ test("should be able to use action more than once for the same event within a vi view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile( + template: compile( '<a id="edit" href="#" {{action "edit"}}>edit</a><a id="delete" href="#" {{action "delete"}}>delete</a>' ), click: function() { originalEventHandlerWasCalled = true; } @@ -429,7 +459,7 @@ test("the event should not bubble if `bubbles=false` is passed", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile( + template: compile( '<a id="edit" href="#" {{action "edit" bubbles=false}}>edit</a><a id="delete" href="#" {{action "delete" bubbles=false}}>delete</a>' ), click: function() { originalEventHandlerWasCalled = true; } @@ -470,7 +500,7 @@ test("should work properly in an #each block", function() { view = EmberView.create({ controller: controller, items: Ember.A([1, 2, 3, 4]), - template: EmberHandlebars.compile('{{#each item in view.items}}<a href="#" {{action "edit"}}>click me</a>{{/each}}') + template: compile('{{#each item in view.items}}<a href="#" {{action "edit"}}>click me</a>{{/each}}') }); appendView(); @@ -490,7 +520,7 @@ test("should work properly in a {{#with foo as bar}} block", function() { view = EmberView.create({ controller: controller, something: {ohai: 'there'}, - template: EmberHandlebars.compile('{{#with view.something as somethingElse}}<a href="#" {{action "edit"}}>click me</a>{{/with}}') + template: compile('{{#with view.something as somethingElse}}<a href="#" {{action "edit"}}>click me</a>{{/with}}') }); appendView(); @@ -510,7 +540,7 @@ test("should work properly in a #with block [DEPRECATED]", function() { view = EmberView.create({ controller: controller, something: {ohai: 'there'}, - template: EmberHandlebars.compile('{{#with view.something}}<a href="#" {{action "edit"}}>click me</a>{{/with}}') + template: compile('{{#with view.something}}<a href="#" {{action "edit"}}>click me</a>{{/with}}') }); expectDeprecation(function() { @@ -526,7 +556,7 @@ test("should unregister event handlers on rerender", function() { var eventHandlerWasCalled = false; view = EmberView.extend({ - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>click me</a>'), + template: compile('<a href="#" {{action "edit"}}>click me</a>'), actions: { edit: function() { eventHandlerWasCalled = true; } } }).create(); @@ -552,7 +582,7 @@ test("should unregister event handlers on inside virtual views", function() { } ]); view = EmberView.create({ - template: EmberHandlebars.compile('{{#each thing in view.things}}<a href="#" {{action "edit"}}>click me</a>{{/each}}'), + template: compile('{{#each thing in view.things}}<a href="#" {{action "edit"}}>click me</a>{{/each}}'), things: things }); @@ -576,7 +606,7 @@ test("should properly capture events on child elements of a container with an ac view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<div {{action "edit"}}><button>click me</button></div>') + template: compile('<div {{action "edit"}}><button>click me</button></div>') }); appendView(); @@ -596,7 +626,7 @@ test("should allow bubbling of events from action helper to original parent even view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>click me</a>'), + template: compile('<a href="#" {{action "edit"}}>click me</a>'), click: function() { originalEventHandlerWasCalled = true; } }); @@ -617,7 +647,7 @@ test("should not bubble an event from action helper to original parent event if view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "edit" bubbles=false}}>click me</a>'), + template: compile('<a href="#" {{action "edit" bubbles=false}}>click me</a>'), click: function() { originalEventHandlerWasCalled = true; } }); @@ -638,7 +668,7 @@ test("should allow 'send' as action name (#594)", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<a href="#" {{action "send" }}>send</a>') + template: compile('<a href="#" {{action "send" }}>send</a>') }); appendView(); @@ -649,7 +679,7 @@ test("should allow 'send' as action name (#594)", function() { }); -test("should send the view, event and current Handlebars context to the action", function() { +test("should send the view, event and current context to the action", function() { var passedTarget; var passedContext; @@ -666,7 +696,7 @@ test("should send the view, event and current Handlebars context to the action", view = EmberView.create({ context: aContext, - template: EmberHandlebars.compile('<a id="edit" href="#" {{action "edit" this target="aTarget"}}>edit</a>') + template: compile('<a id="edit" href="#" {{action "edit" this target=aTarget}}>edit</a>') }); appendView(); @@ -681,7 +711,7 @@ test("should only trigger actions for the event they were registered on", functi var editWasCalled = false; view = EmberView.extend({ - template: EmberHandlebars.compile('<a href="#" {{action "edit"}}>edit</a>'), + template: compile('<a href="#" {{action "edit"}}>edit</a>'), actions: { edit: function() { editWasCalled = true; } } }).create(); @@ -706,7 +736,7 @@ test("should unwrap controllers passed as a context", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<button {{action "edit" this}}>edit</button>') + template: compile('<button {{action "edit" this}}>edit</button>') }); appendView(); @@ -730,7 +760,7 @@ test("should not unwrap controllers passed as `controller`", function() { view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('<button {{action "edit" controller}}>edit</button>') + template: compile('<button {{action "edit" controller}}>edit</button>') }); appendView(); @@ -756,7 +786,7 @@ test("should allow multiple contexts to be specified", function() { controller: controller, modelA: models[0], modelB: models[1], - template: EmberHandlebars.compile('<button {{action "edit" view.modelA view.modelB}}>edit</button>') + template: compile('<button {{action "edit" view.modelA view.modelB}}>edit</button>') }); appendView(); @@ -781,7 +811,7 @@ test("should allow multiple contexts to be specified mixed with string args", fu view = EmberView.create({ controller: controller, modelA: model, - template: EmberHandlebars.compile('<button {{action "edit" "herp" view.modelA}}>edit</button>') + template: compile('<button {{action "edit" "herp" view.modelA}}>edit</button>') }); appendView(); @@ -791,10 +821,6 @@ test("should allow multiple contexts to be specified mixed with string args", fu deepEqual(passedParams, ["herp", model], "the action was called with the passed contexts"); }); -var compile = function(string) { - return EmberHandlebars.compile(string); -}; - test("it does not trigger action with special clicks", function() { var showCalled = false; @@ -944,7 +970,7 @@ test("a quoteless parameter should allow dynamic lookup of the actionName", func var actionOrder = []; view = EmberView.create({ - template: compile("<a id='woot-bound-param'' {{action hookMeUp}}>Hi</a>") + template: compile("<a id='woot-bound-param' {{action hookMeUp}}>Hi</a>") }); var controller = EmberController.extend({ @@ -1089,37 +1115,7 @@ test("a quoteless parameter should resolve actionName, including path", function deepEqual(actionOrder, ['whompWhomp', 'sloopyDookie', 'biggityBoom'], 'action name was looked up properly'); }); -test("a quoteless parameter that also exists as an action name functions properly", function(){ - expectDeprecation('You specified a quoteless path to the {{action}} helper \'ohNoeNotValid\' which did not resolve to an actionName. Perhaps you meant to use a quoted actionName? (e.g. {{action \'ohNoeNotValid\'}}).'); - var triggeredAction; - - view = EmberView.create({ - template: compile("<a id='oops-bound-param'' {{action ohNoeNotValid}}>Hi</a>") - }); - - var controller = EmberController.extend({ - actions: { - ohNoeNotValid: function() { - triggeredAction = true; - } - } - }).create(); - - run(function() { - view.set('controller', controller); - view.appendTo('#qunit-fixture'); - }); - - run(function(){ - view.$("#oops-bound-param").click(); - }); - - ok(triggeredAction, 'the action was triggered'); -}); - -test("a quoteless parameter that also exists as an action name results in a deprecation", function(){ - expectDeprecation('You specified a quoteless path to the {{action}} helper \'ohNoeNotValid\' which did not resolve to an actionName. Perhaps you meant to use a quoted actionName? (e.g. {{action \'ohNoeNotValid\'}}).'); - +test("a quoteless parameter that does not resolve to a value asserts", function(){ var triggeredAction; view = EmberView.create({ @@ -1139,25 +1135,27 @@ test("a quoteless parameter that also exists as an action name results in a depr view.appendTo('#qunit-fixture'); }); - run(function(){ - view.$("#oops-bound-param").click(); - }); - - ok(triggeredAction, 'the action was triggered'); + expectAssertion(function(){ + run(function(){ + view.$("#oops-bound-param").click(); + }); + }, "You specified a quoteless path to the {{action}} helper " + + "which did not resolve to an action name (a string). " + + "Perhaps you meant to use a quoted actionName? (e.g. {{action 'save'}})."); }); -QUnit.module("Ember.Handlebars - action helper - deprecated invoking directly on target", { +QUnit.module("ember-routing-htmlbars: action helper - deprecated invoking directly on target", { setup: function() { - originalActionHelper = EmberHandlebars.helpers['action']; - EmberHandlebars.registerHelper('action', actionHelper); + originalActionHelper = helpers['action']; + registerHelper('action', actionHelper); dispatcher = EventDispatcher.create(); dispatcher.setup(); }, teardown: function() { - delete EmberHandlebars.helpers['action']; - EmberHandlebars.helpers['action'] = originalActionHelper; + delete helpers['action']; + helpers['action'] = originalActionHelper; run(function() { dispatcher.destroy();
true
Other
emberjs
ember.js
932bab101f01d59b41706294ae3a11fe1b2f7fc0.json
Implement HTMLBars `each` helper
packages/ember-htmlbars/lib/helpers/each.js
@@ -0,0 +1,306 @@ + +/** +@module ember +@submodule ember-handlebars +*/ +import Ember from "ember-metal/core"; // Ember.assert; + + +import { fmt } from "ember-runtime/system/string"; +import { get } from "ember-metal/property_get"; +import { set } from "ember-metal/property_set"; +import CollectionView from "ember-views/views/collection_view"; +import { Binding } from "ember-metal/binding"; +import ControllerMixin from "ember-runtime/mixins/controller"; +import ArrayController from "ember-runtime/controllers/array_controller"; +import EmberArray from "ember-runtime/mixins/array"; +import { collectionHelper } from "ember-htmlbars/helpers/collection"; + +import { + addObserver, + removeObserver, + addBeforeObserver, + removeBeforeObserver +} from "ember-metal/observer"; + +import _MetamorphView from "ember-views/views/metamorph_view"; +import { _Metamorph } from "ember-views/views/metamorph_view"; + +var EachView = CollectionView.extend(_Metamorph, { + + init: function() { + var itemController = get(this, 'itemController'); + var binding; + + if (itemController) { + var controller = get(this, 'controller.container').lookupFactory('controller:array').create({ + _isVirtual: true, + parentController: get(this, 'controller'), + itemController: itemController, + target: get(this, 'controller'), + _eachView: this + }); + + this.disableContentObservers(function() { + set(this, 'content', controller); + binding = new Binding('content', '_eachView.dataSource').oneWay(); + binding.connect(controller); + }); + + set(this, '_arrayController', controller); + } else { + this.disableContentObservers(function() { + binding = new Binding('content', 'dataSource').oneWay(); + binding.connect(this); + }); + } + + return this._super(); + }, + + _assertArrayLike: function(content) { + Ember.assert(fmt("The value that #each loops over must be an Array. You " + + "passed %@, but it should have been an ArrayController", + [content.constructor]), + !ControllerMixin.detect(content) || + (content && content.isGenerated) || + content instanceof ArrayController); + Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@", + [(ControllerMixin.detect(content) && + content.get('model') !== undefined) ? + fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]), + EmberArray.detect(content)); + }, + + disableContentObservers: function(callback) { + removeBeforeObserver(this, 'content', null, '_contentWillChange'); + removeObserver(this, 'content', null, '_contentDidChange'); + + callback.call(this); + + addBeforeObserver(this, 'content', null, '_contentWillChange'); + addObserver(this, 'content', null, '_contentDidChange'); + }, + + itemViewClass: _MetamorphView, + emptyViewClass: _MetamorphView, + + createChildView: function(view, attrs) { + view = this._super(view, attrs); + + var content = get(view, 'content'); + var keyword = get(this, 'keyword'); + + if (keyword) { + view._keywords[keyword] = content; + } + + // If {{#each}} is looping over an array of controllers, + // point each child view at their respective controller. + if (content && content.isController) { + set(view, 'controller', content); + } + + return view; + }, + + destroy: function() { + if (!this._super()) { return; } + + var arrayController = get(this, '_arrayController'); + + if (arrayController) { + arrayController.destroy(); + } + + return this; + } +}); + +/** + The `{{#each}}` helper loops over elements in a collection. It is an extension + of the base Handlebars `{{#each}}` helper. + + The default behavior of `{{#each}}` is to yield its inner block once for every + item in an array. + + ```javascript + var developers = [{name: 'Yehuda'},{name: 'Tom'}, {name: 'Paul'}]; + ``` + + ```handlebars + {{#each person in developers}} + {{person.name}} + {{! `this` is whatever it was outside the #each }} + {{/each}} + ``` + + The same rules apply to arrays of primitives, but the items may need to be + references with `{{this}}`. + + ```javascript + var developerNames = ['Yehuda', 'Tom', 'Paul'] + ``` + + ```handlebars + {{#each name in developerNames}} + {{name}} + {{/each}} + ``` + + ### {{else}} condition + + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. + + ``` + {{#each person in developers}} + {{person.name}} + {{else}} + <p>Sorry, nobody is available for this task.</p> + {{/each}} + ``` + + ### Specifying an alternative view for each item + + `itemViewClass` can control which view will be used during the render of each + item's template. + + The following template: + + ```handlebars + <ul> + {{#each developer in developers itemViewClass="person"}} + {{developer.name}} + {{/each}} + </ul> + ``` + + Will use the following view for each item + + ```javascript + App.PersonView = Ember.View.extend({ + tagName: 'li' + }); + ``` + + Resulting in HTML output that looks like the following: + + ```html + <ul> + <li class="ember-view">Yehuda</li> + <li class="ember-view">Tom</li> + <li class="ember-view">Paul</li> + </ul> + ``` + + `itemViewClass` also enables a non-block form of `{{each}}`. The view + must {{#crossLink "Ember.View/toc_templates"}}provide its own template{{/crossLink}}, + and then the block should be dropped. An example that outputs the same HTML + as the previous one: + + ```javascript + App.PersonView = Ember.View.extend({ + tagName: 'li', + template: '{{developer.name}}' + }); + ``` + + ```handlebars + <ul> + {{each developer in developers itemViewClass="person"}} + </ul> + ``` + + ### Specifying an alternative view for no items (else) + + The `emptyViewClass` option provides the same flexibility to the `{{else}}` + case of the each helper. + + ```javascript + App.NoPeopleView = Ember.View.extend({ + tagName: 'li', + template: 'No person is available, sorry' + }); + ``` + + ```handlebars + <ul> + {{#each developer in developers emptyViewClass="no-people"}} + <li>{{developer.name}}</li> + {{/each}} + </ul> + ``` + + ### Wrapping each item in a controller + + Controllers in Ember manage state and decorate data. In many cases, + providing a controller for each item in a list can be useful. + Specifically, an {{#crossLink "Ember.ObjectController"}}Ember.ObjectController{{/crossLink}} + should probably be used. Item controllers are passed the item they + will present as a `model` property, and an object controller will + proxy property lookups to `model` for us. + + This allows state and decoration to be added to the controller + while any other property lookups are delegated to the model. An example: + + ```javascript + App.RecruitController = Ember.ObjectController.extend({ + isAvailableForHire: function() { + return !this.get('isEmployed') && this.get('isSeekingWork'); + }.property('isEmployed', 'isSeekingWork') + }) + ``` + + ```handlebars + {{#each person in developers itemController="recruit"}} + {{person.name}} {{#if person.isAvailableForHire}}Hire me!{{/if}} + {{/each}} + ``` + + @method each + @for Ember.Handlebars.helpers + @param [name] {String} name for item (used with `in`) + @param [path] {String} path + @param [options] {Object} Handlebars key/value pairs of options + @param [options.itemViewClass] {String} a path to a view class used for each item + @param [options.emptyViewClass] {String} a path to a view class used for each item + @param [options.itemController] {String} name of a controller to be created for each item +*/ +function eachHelper(params, hash, options, env) { + var helperName = 'each'; + var keywordName; + var path = params[0]; + + Ember.assert("If you pass more than one argument to the each helper," + + " it must be in the form #each foo in bar", params.length <= 1); + + if (options.types[0] === 'keyword') { + keywordName = path.to; + + helperName += ' ' + keywordName + ' in ' + path.from; + + hash.keyword = keywordName; + + path = path.stream; + } else { + helperName += ' ' + path; + } + + if (!path) { + path = env.data.view.getStream(''); + } + + Ember.deprecate('Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each foo in bar}}`) instead. See http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope for more details.', keywordName); + + hash.emptyViewClass = Ember._MetamorphView; + hash.dataSourceBinding = path; + options.helperName = options.helperName || helperName; + + return collectionHelper.call(this, [EachView], hash, options, env); +} + +export { + EachView, + eachHelper +}; \ No newline at end of file
true
Other
emberjs
ember.js
932bab101f01d59b41706294ae3a11fe1b2f7fc0.json
Implement HTMLBars `each` helper
packages/ember-htmlbars/lib/hooks.js
@@ -10,6 +10,13 @@ function streamifyArgs(view, params, hash, options, env) { stream: view.getStream(params[0]) }); options.types.splice(0, 3, 'keyword'); + } else if (params.length === 3 && params[1] === "in") { + params.splice(0, 3, { + from: params[2], + to: params[0], + stream: view.getStream(params[2]) + }); + options.types.splice(0, 3, 'keyword'); } else { // Convert ID params to streams for (var i = 0, l = params.length; i < l; i++) {
true
Other
emberjs
ember.js
932bab101f01d59b41706294ae3a11fe1b2f7fc0.json
Implement HTMLBars `each` helper
packages/ember-htmlbars/lib/main.js
@@ -35,6 +35,7 @@ import { templateHelper } from "ember-htmlbars/helpers/template"; import { inputHelper } from "ember-htmlbars/helpers/input"; import { textareaHelper } from "ember-htmlbars/helpers/text_area"; import { collectionHelper } from "ember-htmlbars/helpers/collection"; +import { eachHelper } from "ember-htmlbars/helpers/each"; registerHelper('bindHelper', bindHelper); registerHelper('bind', bindHelper); @@ -55,6 +56,7 @@ registerHelper('bindAttr', bindAttrHelperDeprecated); registerHelper('input', inputHelper); registerHelper('textarea', textareaHelper); registerHelper('collection', collectionHelper); +registerHelper('each', eachHelper); if (Ember.FEATURES.isEnabled('ember-htmlbars')) { Ember.HTMLBars = {
true
Other
emberjs
ember.js
932bab101f01d59b41706294ae3a11fe1b2f7fc0.json
Implement HTMLBars `each` helper
packages/ember-htmlbars/lib/system/lookup-helper.js
@@ -8,19 +8,19 @@ export var ISNT_HELPER_CACHE = new Cache(1000, function(key) { return key.indexOf('-') === -1; }); -export function attribute(element, params, options, env) { +export function attribute(params, hash, options, env) { var dom = env.dom; var name = params[0]; var value = params[1]; value.subscribe(function(lazyValue) { - dom.setAttribute(element, name, lazyValue.value()); + dom.setAttribute(options.element, name, lazyValue.value()); }); - dom.setAttribute(element, name, value.value()); + dom.setAttribute(options.element, name, value.value()); } -export function concat(params, options) { +export function concat(params, hash, options, env) { var stream = new Stream(function() { return readArray(params).join(''); });
true
Other
emberjs
ember.js
932bab101f01d59b41706294ae3a11fe1b2f7fc0.json
Implement HTMLBars `each` helper
packages/ember-htmlbars/tests/helpers/each_test.js
@@ -16,11 +16,19 @@ import Container from "ember-runtime/system/container"; import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; +var compile; +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + compile = htmlbarsCompile; +} else { + compile = EmberHandlebars.compile; +} + var people, view, container; var template, templateMyView, MyView; function templateFor(template) { - return EmberHandlebars.compile(template); + return compile(template); } var originalLookup = Ember.lookup; @@ -471,10 +479,14 @@ test("it supports {{itemViewClass=}} with global (DEPRECATED)", function() { people: people }); + var deprecation = /Resolved the view "MyView" on the global context/; + if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + deprecation = /Global lookup of MyView from a Handlebars template is deprecated/; + } expectDeprecation(function(){ append(view); - }, /Resolved the view "MyView" on the global context/); + }, deprecation); assertText(view, "Steve HoltAnnabelle"); }); @@ -732,7 +744,7 @@ test("controller is assignable inside an #each", function() { test("it doesn't assert when the morph tags have the same parent", function() { view = EmberView.create({ controller: A(['Cyril', 'David']), - template: templateFor('<table><tbody>{{#each name in this}}<tr><td>{{name}}</td></tr>{{/each}}<tbody></table>') + template: templateFor('<table><tbody>{{#each name in this}}<tr><td>{{name}}</td></tr>{{/each}}</tbody></table>') }); append(view);
true
Other
emberjs
ember.js
01d5f0680da11f305160e3b1d62abcf1b9249a5b.json
Implement HTMLBars `collection` helper
packages/ember-handlebars/tests/handlebars_test.js
@@ -14,8 +14,6 @@ import { A } from "ember-runtime/system/native_array"; import { computed } from "ember-metal/computed"; import { fmt } from "ember-runtime/system/string"; import { typeOf } from "ember-metal/utils"; -import ArrayProxy from "ember-runtime/system/array_proxy"; -import CollectionView from "ember-views/views/collection_view"; import ContainerView from "ember-views/views/container_view"; import { Binding } from "ember-metal/binding"; import { observersFor } from "ember-metal/observer"; @@ -1015,90 +1013,6 @@ test("Child views created using the view helper and that have a viewName should equal(get(parentView, 'ohai'), childView); }); -test("Collection views that specify an example view class have their children be of that class", function() { - var ExampleViewCollection = CollectionView.extend({ - itemViewClass: EmberView.extend({ - isCustom: true - }), - - content: A(['foo']) - }); - - view = EmberView.create({ - exampleViewCollection: ExampleViewCollection, - template: EmberHandlebars.compile('{{#collection view.exampleViewCollection}}OHAI{{/collection}}') - }); - - run(function() { - view.append(); - }); - - ok(firstGrandchild(view).isCustom, "uses the example view class"); -}); - -test("itemViewClass works in the #collection helper with a global (DEPRECATED)", function() { - TemplateTests.ExampleItemView = EmberView.extend({ - isAlsoCustom: true - }); - - view = EmberView.create({ - exampleController: ArrayProxy.create({ - content: A(['alpha']) - }), - template: EmberHandlebars.compile('{{#collection content=view.exampleController itemViewClass=TemplateTests.ExampleItemView}}beta{{/collection}}') - }); - - expectDeprecation(function(){ - run(view, 'append'); - }, /Resolved the view "TemplateTests.ExampleItemView" on the global context/); - - ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); -}); - -test("itemViewClass works in the #collection helper with a property", function() { - var ExampleItemView = EmberView.extend({ - isAlsoCustom: true - }); - - var ExampleCollectionView = CollectionView; - - view = EmberView.create({ - possibleItemView: ExampleItemView, - exampleCollectionView: ExampleCollectionView, - exampleController: ArrayProxy.create({ - content: A(['alpha']) - }), - template: EmberHandlebars.compile('{{#collection view.exampleCollectionView content=view.exampleController itemViewClass=view.possibleItemView}}beta{{/collection}}') - }); - - run(function() { - view.append(); - }); - - ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); -}); - -test("itemViewClass works in the #collection via container", function() { - container.register('view:example-item', EmberView.extend({ - isAlsoCustom: true - })); - - view = EmberView.create({ - container: container, - exampleCollectionView: CollectionView.extend(), - exampleController: ArrayProxy.create({ - content: A(['alpha']) - }), - template: EmberHandlebars.compile('{{#collection view.exampleCollectionView content=view.exampleController itemViewClass="example-item"}}beta{{/collection}}') - }); - - run(function() { - view.append(); - }); - - ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); -}); - test("should update boundIf blocks if the conditional changes", function() { container.register('template:foo', EmberHandlebars.compile('<h1 id="first">{{#boundIf "view.content.myApp.isEnabled"}}{{view.content.wham}}{{/boundIf}}</h1>'));
true
Other
emberjs
ember.js
01d5f0680da11f305160e3b1d62abcf1b9249a5b.json
Implement HTMLBars `collection` helper
packages/ember-htmlbars/lib/helpers/collection.js
@@ -0,0 +1,267 @@ +/** +@module ember +@submodule ember-handlebars +*/ + +import Ember from "ember-metal/core"; // Ember.assert, Ember.deprecate +import EmberHandlebars from "ember-handlebars-compiler"; + +import { IS_BINDING } from "ember-metal/mixin"; +import { fmt } from "ember-runtime/system/string"; +import { get } from "ember-metal/property_get"; +import SimpleStream from "ember-metal/streams/simple"; +import { ViewHelper } from "ember-handlebars/helpers/view"; +import alias from "ember-metal/alias"; +import View from "ember-views/views/view"; +import CollectionView from "ember-views/views/collection_view"; +import { viewHelper } from "ember-htmlbars/helpers/view"; +import { readViewFactory } from "ember-views/streams/read"; + +/** + `{{collection}}` is a `Ember.Handlebars` helper for adding instances of + `Ember.CollectionView` to a template. See [Ember.CollectionView](/api/classes/Ember.CollectionView.html) + for additional information on how a `CollectionView` functions. + + `{{collection}}`'s primary use is as a block helper with a `contentBinding` + option pointing towards an `Ember.Array`-compatible object. An `Ember.View` + instance will be created for each item in its `content` property. Each view + will have its own `content` property set to the appropriate item in the + collection. + + The provided block will be applied as the template for each item's view. + + Given an empty `<body>` the following template: + + ```handlebars + {{! application.hbs }} + {{#collection content=model}} + Hi {{view.content.name}} + {{/collection}} + ``` + + And the following application code + + ```javascript + App = Ember.Application.create(); + App.ApplicationRoute = Ember.Route.extend({ + model: function(){ + return [{name: 'Yehuda'},{name: 'Tom'},{name: 'Peter'}]; + } + }); + ``` + + The following HTML will result: + + ```html + <div class="ember-view"> + <div class="ember-view">Hi Yehuda</div> + <div class="ember-view">Hi Tom</div> + <div class="ember-view">Hi Peter</div> + </div> + ``` + + ### Non-block version of collection + + If you provide an `itemViewClass` option that has its own `template` you may + omit the block. + + The following template: + + ```handlebars + {{! application.hbs }} + {{collection content=model itemViewClass="an-item"}} + ``` + + And application code + + ```javascript + App = Ember.Application.create(); + App.ApplicationRoute = Ember.Route.extend({ + model: function(){ + return [{name: 'Yehuda'},{name: 'Tom'},{name: 'Peter'}]; + } + }); + + App.AnItemView = Ember.View.extend({ + template: Ember.Handlebars.compile("Greetings {{view.content.name}}") + }); + ``` + + Will result in the HTML structure below + + ```html + <div class="ember-view"> + <div class="ember-view">Greetings Yehuda</div> + <div class="ember-view">Greetings Tom</div> + <div class="ember-view">Greetings Peter</div> + </div> + ``` + + ### Specifying a CollectionView subclass + + By default the `{{collection}}` helper will create an instance of + `Ember.CollectionView`. You can supply a `Ember.CollectionView` subclass to + the helper by passing it as the first argument: + + ```handlebars + {{#collection "my-custom-collection" content=model}} + Hi {{view.content.name}} + {{/collection}} + ``` + + This example would look for the class `App.MyCustomCollection`. + + ### Forwarded `item.*`-named Options + + As with the `{{view}}`, helper options passed to the `{{collection}}` will be + set on the resulting `Ember.CollectionView` as properties. Additionally, + options prefixed with `item` will be applied to the views rendered for each + item (note the camelcasing): + + ```handlebars + {{#collection content=model + itemTagName="p" + itemClassNames="greeting"}} + Howdy {{view.content.name}} + {{/collection}} + ``` + + Will result in the following HTML structure: + + ```html + <div class="ember-view"> + <p class="ember-view greeting">Howdy Yehuda</p> + <p class="ember-view greeting">Howdy Tom</p> + <p class="ember-view greeting">Howdy Peter</p> + </div> + ``` + + @method collection + @for Ember.Handlebars.helpers + @param {String} path + @param {Hash} options + @return {String} HTML string + @deprecated Use `{{each}}` helper instead. +*/ +export function collectionHelper(params, hash, options, env) { + var path = params[0]; + + Ember.deprecate("Using the {{collection}} helper without specifying a class has been" + + " deprecated as the {{each}} helper now supports the same functionality.", path !== 'collection'); + + Ember.assert("You cannot pass more than one argument to the collection helper", params.length <= 1); + + var fn = options.render, + data = env.data, + inverse = options.inverse, + view = data.view, + // This should be deterministic, and should probably come from a + // parent view and not the controller. + container = (view.controller && view.controller.container ? view.controller.container : view.container); + + // If passed a path string, convert that into an object. + // Otherwise, just default to the standard class. + var collectionClass; + if (path) { + collectionClass = readViewFactory(path, container); + Ember.assert(fmt("%@ #collection: Could not find collection class %@", [data.view, path]), !!collectionClass); + } + else { + collectionClass = CollectionView; + } + + var hashTypes = options.hashTypes; + var itemHash = {}; + var match; + + // Extract item view class if provided else default to the standard class + var collectionPrototype = collectionClass.proto(); + var itemViewClass; + + if (hash.itemView) { + itemViewClass = readViewFactory(hash.itemView, container); + } else if (hash.itemViewClass) { + itemViewClass = readViewFactory(hash.itemViewClass, container); + } else { + itemViewClass = collectionPrototype.itemViewClass; + } + + if (typeof itemViewClass === 'string') { + itemViewClass = container.lookupFactory('view:'+itemViewClass); + } + + Ember.assert(fmt("%@ #collection: Could not find itemViewClass %@", [data.view, itemViewClass]), !!itemViewClass); + + delete hash.itemViewClass; + delete hash.itemView; + delete hashTypes.itemViewClass; + delete hashTypes.itemView; + + // Go through options passed to the {{collection}} helper and extract options + // that configure item views instead of the collection itself. + for (var prop in hash) { + if (prop === 'itemController' || prop === 'itemClassBinding') { + continue; + } + if (hash.hasOwnProperty(prop)) { + match = prop.match(/^item(.)(.*)$/); + if (match) { + var childProp = match[1].toLowerCase() + match[2]; + + if (IS_BINDING.test(prop)) { + itemHash[childProp] = view._getBindingForStream(hash[prop]); + } else { + itemHash[childProp] = hash[prop]; + } + delete hash[prop]; + } + } + } + + if (fn) { + itemHash.template = fn; + delete options.render; + } + + var emptyViewClass; + if (inverse && inverse !== EmberHandlebars.VM.noop) { + emptyViewClass = get(collectionPrototype, 'emptyViewClass'); + emptyViewClass = emptyViewClass.extend({ + template: inverse, + tagName: itemHash.tagName + }); + } else if (hash.emptyViewClass) { + emptyViewClass = readViewFactory(hash.emptyViewClass, container); + } + if (emptyViewClass) { hash.emptyView = emptyViewClass; } + + if (hash.keyword) { + itemHash._context = alias('_parentView.context'); + } else { + itemHash._context = alias('content'); + } + + var viewOptions = ViewHelper.propertiesFromHTMLOptions({ data: data, hash: itemHash }, this); + + if (hash.itemClassBinding) { + var itemClassBindings = hash.itemClassBinding.split(' '); + + for (var i = 0; i < itemClassBindings.length; i++) { + var parsedPath = View._parsePropertyPath(itemClassBindings[i]); + if (parsedPath.path === '') { + parsedPath.stream = new SimpleStream(true); + } else { + parsedPath.stream = view.getStream(parsedPath.path); + } + itemClassBindings[i] = parsedPath; + } + + viewOptions.classNameBindings = itemClassBindings; + } + + hash.itemViewClass = itemViewClass.extend(viewOptions); + + options.helperName = options.helperName || 'collection'; + + return viewHelper.call(this, [collectionClass], hash, options, env); +}
true
Other
emberjs
ember.js
01d5f0680da11f305160e3b1d62abcf1b9249a5b.json
Implement HTMLBars `collection` helper
packages/ember-htmlbars/lib/main.js
@@ -34,6 +34,7 @@ import { partialHelper } from "ember-htmlbars/helpers/partial"; import { templateHelper } from "ember-htmlbars/helpers/template"; import { inputHelper } from "ember-htmlbars/helpers/input"; import { textareaHelper } from "ember-htmlbars/helpers/text_area"; +import { collectionHelper } from "ember-htmlbars/helpers/collection"; registerHelper('bindHelper', bindHelper); registerHelper('bind', bindHelper); @@ -53,6 +54,7 @@ registerHelper('bind-attr', bindAttrHelper); registerHelper('bindAttr', bindAttrHelperDeprecated); registerHelper('input', inputHelper); registerHelper('textarea', textareaHelper); +registerHelper('collection', collectionHelper); if (Ember.FEATURES.isEnabled('ember-htmlbars')) { Ember.HTMLBars = {
true
Other
emberjs
ember.js
01d5f0680da11f305160e3b1d62abcf1b9249a5b.json
Implement HTMLBars `collection` helper
packages/ember-htmlbars/tests/helpers/collection_test.js
@@ -1,47 +1,158 @@ /*jshint newcap:false*/ - +import CollectionView from "ember-views/views/collection_view"; +import EmberObject from "ember-runtime/system/object"; import EmberView from "ember-views/views/view"; +import EmberHandlebars from "ember-handlebars"; +import ArrayProxy from "ember-runtime/system/array_proxy"; +import Namespace from "ember-runtime/system/namespace"; +import Container from "ember-runtime/system/container"; +import { A } from "ember-runtime/system/native_array"; import run from "ember-metal/run_loop"; +import { get } from "ember-metal/property_get"; +import { set } from "ember-metal/property_set"; import jQuery from "ember-views/system/jquery"; -import EmberObject from "ember-runtime/system/object"; import { computed } from "ember-metal/computed"; -import Namespace from "ember-runtime/system/namespace"; -import ArrayProxy from "ember-runtime/system/array_proxy"; -import CollectionView from "ember-views/views/collection_view"; -import { A } from "ember-runtime/system/native_array"; -import Container from "ember-runtime/system/container"; -import EmberHandlebars from "ember-handlebars-compiler"; var trim = jQuery.trim; -import { get } from "ember-metal/property_get"; -import { set } from "ember-metal/property_set"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; +var compile; +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + compile = htmlbarsCompile; +} else { + compile = EmberHandlebars.compile; +} + +var view; + +var originalLookup = Ember.lookup; +var TemplateTests, container, lookup; + function nthChild(view, nth) { return get(view, 'childViews').objectAt(nth || 0); } var firstChild = nthChild; -var originalLookup = Ember.lookup; -var lookup, TemplateTests, view; +function firstGrandchild(view) { + return get(get(view, 'childViews').objectAt(0), 'childViews').objectAt(0); +} -QUnit.module("ember-handlebars/tests/views/collection_view_test", { +QUnit.module("collection helper", { setup: function() { - Ember.lookup = lookup = { Ember: Ember }; + Ember.lookup = lookup = {}; lookup.TemplateTests = TemplateTests = Namespace.create(); + container = new Container(); + container.optionsForType('template', { instantiate: false }); + // container.register('view:default', _MetamorphView); + container.register('view:toplevel', EmberView.extend()); }, + teardown: function() { run(function() { - if (view) { - view.destroy(); - } + if (container) { + container.destroy(); + } + if (view) { + view.destroy(); + } + container = view = null; }); + Ember.lookup = lookup = originalLookup; + TemplateTests = null; + } +}); + +test("Collection views that specify an example view class have their children be of that class", function() { + var ExampleViewCollection = CollectionView.extend({ + itemViewClass: EmberView.extend({ + isCustom: true + }), + + content: A(['foo']) + }); + + view = EmberView.create({ + exampleViewCollection: ExampleViewCollection, + template: compile('{{#collection view.exampleViewCollection}}OHAI{{/collection}}') + }); - Ember.lookup = originalLookup; + run(function() { + view.append(); + }); + + ok(firstGrandchild(view).isCustom, "uses the example view class"); +}); + +test("itemViewClass works in the #collection helper with a global (DEPRECATED)", function() { + TemplateTests.ExampleItemView = EmberView.extend({ + isAlsoCustom: true + }); + + view = EmberView.create({ + exampleController: ArrayProxy.create({ + content: A(['alpha']) + }), + template: compile('{{#collection content=view.exampleController itemViewClass=TemplateTests.ExampleItemView}}beta{{/collection}}') + }); + + var deprecation = /Resolved the view "TemplateTests.ExampleItemView" on the global context/; + if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + deprecation = /Global lookup of TemplateTests.ExampleItemView from a Handlebars template is deprecated/; } + expectDeprecation(function(){ + run(view, 'append'); + }, deprecation); + + ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); +}); + +test("itemViewClass works in the #collection helper with a property", function() { + var ExampleItemView = EmberView.extend({ + isAlsoCustom: true + }); + + var ExampleCollectionView = CollectionView; + + view = EmberView.create({ + possibleItemView: ExampleItemView, + exampleCollectionView: ExampleCollectionView, + exampleController: ArrayProxy.create({ + content: A(['alpha']) + }), + template: compile('{{#collection view.exampleCollectionView content=view.exampleController itemViewClass=view.possibleItemView}}beta{{/collection}}') + }); + + run(function() { + view.append(); + }); + + ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); }); +test("itemViewClass works in the #collection via container", function() { + container.register('view:example-item', EmberView.extend({ + isAlsoCustom: true + })); + + view = EmberView.create({ + container: container, + exampleCollectionView: CollectionView.extend(), + exampleController: ArrayProxy.create({ + content: A(['alpha']) + }), + template: compile('{{#collection view.exampleCollectionView content=view.exampleController itemViewClass="example-item"}}beta{{/collection}}') + }); + + run(function() { + view.append(); + }); + + ok(firstGrandchild(view).isAlsoCustom, "uses the example view class specified in the #collection helper"); +}); + + test("passing a block to the collection helper sets it as the template for example views", function() { var CollectionTestView = CollectionView.extend({ tagName: 'ul', @@ -50,7 +161,7 @@ test("passing a block to the collection helper sets it as the template for examp view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView}} <label></label> {{/collection}}') + template: compile('{{#collection view.collectionTestView}} <label></label> {{/collection}}') }); run(function() { @@ -73,7 +184,7 @@ test("collection helper should try to use container to resolve view", function() var controller = {container: container}; view = EmberView.create({ controller: controller, - template: EmberHandlebars.compile('{{#collection "collectionTest"}} <label></label> {{/collection}}') + template: compile('{{#collection "collectionTest"}} <label></label> {{/collection}}') }); run(function() { @@ -85,7 +196,7 @@ test("collection helper should try to use container to resolve view", function() test("collection helper should accept relative paths", function() { view = EmberView.create({ - template: EmberHandlebars.compile('{{#collection view.collection}} <label></label> {{/collection}}'), + template: compile('{{#collection view.collection}} <label></label> {{/collection}}'), collection: CollectionView.extend({ tagName: 'ul', content: A(['foo', 'bar', 'baz']) @@ -101,7 +212,7 @@ test("collection helper should accept relative paths", function() { test("empty views should be removed when content is added to the collection (regression, ht: msofaer)", function() { var EmptyView = EmberView.extend({ - template : EmberHandlebars.compile("<td>No Rows Yet</td>") + template : compile("<td>No Rows Yet</td>") }); var ListView = CollectionView.extend({ @@ -115,7 +226,7 @@ test("empty views should be removed when content is added to the collection (reg view = EmberView.create({ listView: ListView, listController: listController, - template: EmberHandlebars.compile('{{#collection view.listView content=view.listController tagName="table"}} <td>{{view.content.title}}</td> {{/collection}}') + template: compile('{{#collection view.listView content=view.listController tagName="table"}} <td>{{view.content.title}}</td> {{/collection}}') }); run(function() { @@ -140,7 +251,7 @@ test("should be able to specify which class should be used for the empty view", }); var EmptyView = EmberView.extend({ - template: EmberHandlebars.compile('This is an empty view') + template: compile('This is an empty view') }); view = EmberView.create({ @@ -149,7 +260,7 @@ test("should be able to specify which class should be used for the empty view", return EmptyView; } }, - template: EmberHandlebars.compile('{{collection emptyViewClass="empty-view"}}') + template: compile('{{collection emptyViewClass="empty-view"}}') }); run(function() { @@ -171,7 +282,7 @@ test("if no content is passed, and no 'else' is specified, nothing is rendered", view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView}} <aside></aside> {{/collection}}') + template: compile('{{#collection view.collectionTestView}} <aside></aside> {{/collection}}') }); run(function() { @@ -189,7 +300,7 @@ test("if no content is passed, and 'else' is specified, the else block is render view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView}} <aside></aside> {{ else }} <del></del> {{/collection}}') + template: compile('{{#collection view.collectionTestView}} <aside></aside> {{ else }} <del></del> {{/collection}}') }); run(function() { @@ -207,7 +318,7 @@ test("a block passed to a collection helper defaults to the content property of view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView}} <label>{{view.content}}</label> {{/collection}}') + template: compile('{{#collection view.collectionTestView}} <label>{{view.content}}</label> {{/collection}}') }); run(function() { @@ -230,7 +341,7 @@ test("a block passed to a collection helper defaults to the view", function() { view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView}} <label>{{view.content}}</label> {{/collection}}') + template: compile('{{#collection view.collectionTestView}} <label>{{view.content}}</label> {{/collection}}') }); run(function() { @@ -259,7 +370,7 @@ test("should include an id attribute if id is set in the options hash", function view = EmberView.create({ collectionTestView: CollectionTestView, - template: EmberHandlebars.compile('{{#collection view.collectionTestView id="baz"}}foo{{/collection}}') + template: compile('{{#collection view.collectionTestView id="baz"}}foo{{/collection}}') }); run(function() { @@ -276,7 +387,7 @@ test("should give its item views the class specified by itemClass", function() { }); view = EmberView.create({ itemClassTestCollectionView: ItemClassTestCollectionView, - template: EmberHandlebars.compile('{{#collection view.itemClassTestCollectionView itemClass="baz"}}foo{{/collection}}') + template: compile('{{#collection view.itemClassTestCollectionView itemClass="baz"}}foo{{/collection}}') }); run(function() { @@ -295,7 +406,7 @@ test("should give its item views the classBinding specified by itemClassBinding" view = EmberView.create({ itemClassBindingTestCollectionView: ItemClassBindingTestCollectionView, isBar: true, - template: EmberHandlebars.compile('{{#collection view.itemClassBindingTestCollectionView itemClassBinding="view.isBar"}}foo{{/collection}}') + template: compile('{{#collection view.itemClassBindingTestCollectionView itemClassBinding="view.isBar"}}foo{{/collection}}') }); run(function() { @@ -323,7 +434,7 @@ test("should give its item views the property specified by itemPropertyBinding", return ItemPropertyBindingTestItemView; } }, - template: EmberHandlebars.compile('{{#collection contentBinding="view.content" tagName="ul" itemViewClass="item-property-binding-test-item-view" itemPropertyBinding="view.baz" preserveContext=false}}{{view.property}}{{/collection}}') + template: compile('{{#collection contentBinding="view.content" tagName="ul" itemViewClass="item-property-binding-test-item-view" itemPropertyBinding="view.baz" preserveContext=false}}{{view.property}}{{/collection}}') }); run(function() { @@ -347,7 +458,7 @@ test("should unsubscribe stream bindings", function() { view = EmberView.create({ baz: "baz", content: A([EmberObject.create(), EmberObject.create(), EmberObject.create()]), - template: EmberHandlebars.compile('{{#collection contentBinding="view.content" itemPropertyBinding="view.baz"}}{{view.property}}{{/collection}}') + template: compile('{{#collection contentBinding="view.content" itemPropertyBinding="view.baz"}}{{view.property}}{{/collection}}') }); run(function() { @@ -374,7 +485,7 @@ test("should work inside a bound {{#if}}", function() { view = EmberView.create({ ifTestCollectionView: IfTestCollectionView, - template: EmberHandlebars.compile('{{#if view.shouldDisplay}}{{#collection view.ifTestCollectionView}}{{content.isBaz}}{{/collection}}{{/if}}'), + template: compile('{{#if view.shouldDisplay}}{{#collection view.ifTestCollectionView}}{{content.isBaz}}{{/collection}}{{/if}}'), shouldDisplay: true }); @@ -393,7 +504,7 @@ test("should work inside a bound {{#if}}", function() { test("should pass content as context when using {{#each}} helper [DEPRECATED]", function() { view = EmberView.create({ - template: EmberHandlebars.compile('{{#each view.releases}}Mac OS X {{version}}: {{name}} {{/each}}'), + template: compile('{{#each view.releases}}Mac OS X {{version}}: {{name}} {{/each}}'), releases: A([ { version: '10.7', @@ -420,7 +531,7 @@ test("should re-render when the content object changes", function() { view = EmberView.create({ rerenderTestView: RerenderTest, - template: EmberHandlebars.compile('{{#collection view.rerenderTestView}}{{view.content}}{{/collection}}') + template: compile('{{#collection view.rerenderTestView}}{{view.content}}{{/collection}}') }); run(function() { @@ -447,7 +558,7 @@ test("select tagName on collection helper automatically sets child tagName to op view = EmberView.create({ rerenderTestView: RerenderTest, - template: EmberHandlebars.compile('{{#collection view.rerenderTestView tagName="select"}}{{view.content}}{{/collection}}') + template: compile('{{#collection view.rerenderTestView tagName="select"}}{{view.content}}{{/collection}}') }); run(function() { @@ -465,7 +576,7 @@ test("tagName works in the #collection helper", function() { view = EmberView.create({ rerenderTestView: RerenderTest, - template: EmberHandlebars.compile('{{#collection view.rerenderTestView tagName="ol"}}{{view.content}}{{/collection}}') + template: compile('{{#collection view.rerenderTestView tagName="ol"}}{{view.content}}{{/collection}}') }); run(function() { @@ -498,7 +609,7 @@ test("should render nested collections", function() { view = EmberView.create({ container: container, - template: EmberHandlebars.compile('{{#collection "outer-list" class="outer"}}{{content}}{{#collection "inner-list" class="inner"}}{{content}}{{/collection}}{{/collection}}') + template: compile('{{#collection "outer-list" class="outer"}}{{content}}{{#collection "inner-list" class="inner"}}{{content}}{{/collection}}{{/collection}}') }); run(function() { @@ -526,7 +637,7 @@ test("should render multiple, bound nested collections (#68)", function() { var OuterListItem = EmberView.extend({ innerListView: InnerList, - template: EmberHandlebars.compile('{{#collection view.innerListView class="inner"}}{{content}}{{/collection}}{{content}}'), + template: compile('{{#collection view.innerListView class="inner"}}{{content}}{{/collection}}{{content}}'), innerListContent: computed(function() { return A([1,2,3]); }) @@ -540,7 +651,7 @@ test("should render multiple, bound nested collections (#68)", function() { view = EmberView.create({ outerListView: OuterList, - template: EmberHandlebars.compile('{{collection view.outerListView class="outer"}}') + template: compile('{{collection view.outerListView class="outer"}}') }); }); @@ -567,15 +678,15 @@ test("should allow view objects to be swapped out without throwing an error (#78 var ExampleCollectionView = CollectionView.extend({ contentBinding: 'parentView.items', tagName: 'ul', - template: EmberHandlebars.compile("{{view.content}}") + template: compile("{{view.content}}") }); var ReportingView = EmberView.extend({ exampleCollectionView: ExampleCollectionView, datasetBinding: 'TemplateTests.datasetController.dataset', readyBinding: 'dataset.ready', itemsBinding: 'dataset.items', - template: EmberHandlebars.compile("{{#if view.ready}}{{collection view.exampleCollectionView}}{{else}}Loading{{/if}}") + template: compile("{{#if view.ready}}{{collection view.exampleCollectionView}}{{else}}Loading{{/if}}") }); view = ReportingView.create(); @@ -621,15 +732,15 @@ test("context should be content", function() { ]); container.register('view:an-item', EmberView.extend({ - template: EmberHandlebars.compile("Greetings {{name}}") + template: compile("Greetings {{name}}") })); view = EmberView.create({ container: container, controller: { items: items }, - template: EmberHandlebars.compile('{{collection contentBinding="items" itemViewClass="an-item"}}') + template: compile('{{collection contentBinding="items" itemViewClass="an-item"}}') }); run(function() {
true
Other
emberjs
ember.js
788c825b27b7c9b884a91635207742de1fcad8c1.json
Add deprecation for quoteless outlet names
packages/ember-routing-handlebars/lib/helpers/outlet.js
@@ -82,6 +82,12 @@ export function outletHelper(property, options) { property = 'main'; } + Ember.deprecate( + "Using {{outlet}} with an unquoted name is not supported. " + + "Please update to quoted usage '{{outlet \"" + property + "\"}}'.", + arguments.length === 1 || options.types[0] === 'STRING' + ); + var view = options.data.view; var container = view.container; @@ -96,9 +102,15 @@ export function outletHelper(property, options) { if (viewName) { viewFullName = 'view:' + viewName; - Ember.assert("Using a quoteless view parameter with {{outlet}} is not supported." + - " Please update to quoted usage '{{outlet \"" + viewName + "\"}}.", options.hashTypes.view !== 'ID'); - Ember.assert("The view name you supplied '" + viewName + "' did not resolve to a view.", container.has(viewFullName)); + Ember.assert( + "Using a quoteless view parameter with {{outlet}} is not supported." + + " Please update to quoted usage '{{outlet ... view=\"" + viewName + "\"}}.", + options.hashTypes.view !== 'ID' + ); + Ember.assert( + "The view name you supplied '" + viewName + "' did not resolve to a view.", + container.has(viewFullName) + ); } viewClass = viewName ? container.lookupFactory(viewFullName) : options.hash.viewClass || OutletView;
true
Other
emberjs
ember.js
788c825b27b7c9b884a91635207742de1fcad8c1.json
Add deprecation for quoteless outlet names
packages/ember-routing-htmlbars/lib/helpers/outlet.js
@@ -77,8 +77,10 @@ export function outletHelper(params, hash, options, env) { var viewClass; var viewFullName; - Ember.assert("Outlet names must be a string literal, e.g. {{outlet \"header\"}}", - params.length === 0 || options.types[0] === 'string'); + Ember.assert( + "Using {{outlet}} with an unquoted name is not supported.", + params.length === 0 || options.types[0] === 'string' + ); var property = params[0] || 'main'; @@ -93,9 +95,15 @@ export function outletHelper(params, hash, options, env) { if (viewName) { viewFullName = 'view:' + viewName; - Ember.assert("Using a quoteless view parameter with {{outlet}} is not supported." + - " Please update to quoted usage '{{outlet \"" + viewName + "\"}}.", options.hashTypes.view === 'string'); - Ember.assert("The view name you supplied '" + viewName + "' did not resolve to a view.", this.container.has(viewFullName)); + Ember.assert( + "Using a quoteless view parameter with {{outlet}} is not supported." + + " Please update to quoted usage '{{outlet ... view=\"" + viewName + "\"}}.", + options.hashTypes.view === 'string' + ); + Ember.assert( + "The view name you supplied '" + viewName + "' did not resolve to a view.", + this.container.has(viewFullName) + ); } viewClass = viewName ? this.container.lookupFactory(viewFullName) : hash.viewClass || OutletView;
true
Other
emberjs
ember.js
788c825b27b7c9b884a91635207742de1fcad8c1.json
Add deprecation for quoteless outlet names
packages/ember-routing-htmlbars/tests/helpers/outlet_test.js
@@ -380,3 +380,39 @@ test("should support layouts", function() { // Replace whitespace for older IE equal(trim(view.$().text()), 'HIBYE'); }); + +test("should not throw deprecations if {{outlet}} is used without a name", function() { + expectNoDeprecation(); + view = EmberView.create({ + template: compile("{{outlet}}") + }); + appendView(view); +}); + +test("should not throw deprecations if {{outlet}} is used with a quoted name", function() { + expectNoDeprecation(); + view = EmberView.create({ + template: compile("{{outlet \"foo\"}}"), + }); + appendView(view); +}); + +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + test("should throw an assertion if {{outlet}} used with unquoted name", function() { + view = EmberView.create({ + template: compile("{{outlet foo}}"), + }); + expectAssertion(function() { + appendView(view); + }, "Using {{outlet}} with an unquoted name is not supported."); + }); +} else { + test("should throw a deprecation if {{outlet}} is used with an unquoted name", function() { + view = EmberView.create({ + template: compile("{{outlet foo}}") + }); + expectDeprecation(function() { + appendView(view); + }, 'Using {{outlet}} with an unquoted name is not supported. Please update to quoted usage \'{{outlet "foo"}}\'.'); + }); +}
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
Brocfile.js
@@ -16,7 +16,6 @@ var replace = require('broccoli-replace'); var es3recast = require('broccoli-es3-safe-recast'); var useStrictRemover = require('broccoli-use-strict-remover'); var derequire = require('broccoli-derequire'); -var htmlbarsHandlebarsInliner = require('htmlbars/build-support/handlebars-inliner'); var getVersion = require('git-repo-version'); var yuidocPlugin = require('ember-cli-yuidoc'); @@ -355,9 +354,9 @@ var vendoredPackages = { 'route-recognizer': vendoredEs6Package('route-recognizer'), 'dag-map': vendoredEs6Package('dag-map'), 'morph': htmlbarsPackage('morph'), - 'htmlbars': htmlbarsPackage('htmlbars-runtime'), 'htmlbars-compiler': htmlbarsPackage('htmlbars-compiler'), - 'simple-html-tokenizer': vendoredEs6Package('simple-html-tokenizer'), + 'simple-html-tokenizer': htmlbarsPackage('simple-html-tokenizer'), + 'htmlbars-test-helpers': htmlbarsPackage('htmlbars-test-helpers', { singleFile: true } ), 'handlebars': vendoredPackage('handlebars', handlebarsConfig) }; @@ -620,50 +619,31 @@ compiledPackageTrees = mergeTrees(compiledPackageTrees); vendorTrees = mergeTrees(vendorTrees); devSourceTrees = mergeTrees(devSourceTrees); -// Grab the HTMLBars test helpers and make them appear they are coming from -// the ember-htmlbars package. -testHelpers = htmlbarsTestHelpers('assertions', 'ember-htmlbars/tests/helpers'); -testTrees.push(testHelpers); testTrees = mergeTrees(testTrees); -function htmlbarsPackage(packageName) { - var trees = []; - - var tree = pickFiles('node_modules/htmlbars/packages/' + packageName + '/lib', { - srcDir: '/', - destDir: '/' + packageName - }); - - tree = moveFile(tree, { - srcFile: '/' + packageName + '/main.js', - destFile: packageName + '.js' - }); +function htmlbarsPackage(packageName, _options) { + var options = _options || {}; + var fileGlobs = [packageName + '.js']; - trees.push(tree); - - if (packageName === 'htmlbars-compiler') { - trees.push(htmlbarsHandlebarsInliner); + if (!options.singleFile === true) { + fileGlobs.push(packageName + '/**/*.js'); } - tree = transpileES6(mergeTrees(trees), { - moduleName: true - }); - - return useStrictRemover(tree); -} - -function htmlbarsTestHelpers(helper, rename) { - var tree = pickFiles('node_modules/htmlbars/test/support', { - files: [helper + '.js'], + var tree = pickFiles('node_modules/htmlbars/dist/es6/', { + files: fileGlobs, srcDir: '/', destDir: '/' }); - return moveFile(tree, { - srcFile: '/' + helper + '.js', - destFile: '/' + rename + '.js' + tree = transpileES6(tree, { + moduleName: true }); + + if (env !== 'development' && !disableES3) { + tree = es3recast(tree); + } + return tree; } /*
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
bower.json
@@ -12,8 +12,7 @@ "router.js": "https://github.com/tildeio/router.js.git#f7b4b11543222c52d91df861544592a8c1dcea8a", "route-recognizer": "https://github.com/tildeio/route-recognizer.git#8e1058e29de741b8e05690c69da9ec402a167c69", "dag-map": "https://github.com/krisselden/dag-map.git#e307363256fe918f426e5a646cb5f5062d3245be", - "ember-dev": "https://github.com/emberjs/ember-dev.git#1c30a1666273ab2a9b134a42bad28c774f9ecdfc", - "simple-html-tokenizer": "tildeio/simple-html-tokenizer#83952381ed525eaff9b81c79ccd2ae5af1c9ed9f" + "ember-dev": "https://github.com/emberjs/ember-dev.git#1c30a1666273ab2a9b134a42bad28c774f9ecdfc" }, "resolutions": { "handlebars": "~2.0.0"
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
lib/packages.js
@@ -9,7 +9,7 @@ module.exports = { 'ember-testing': {trees: null, requirements: ['ember-application', 'ember-routing'], developmentOnly: true}, 'ember-handlebars-compiler': {trees: null, requirements: ['ember-views']}, 'ember-handlebars': {trees: null, requirements: ['ember-views', 'ember-handlebars-compiler']}, - 'ember-htmlbars': {trees: null, vendorRequirements: ['htmlbars', 'handlebars', 'simple-html-tokenizer', 'htmlbars-compiler'], requirements: ['ember-metal-views']}, + 'ember-htmlbars': {trees: null, vendorRequirements: ['handlebars', 'simple-html-tokenizer', 'htmlbars-compiler', 'htmlbars-test-helpers'], requirements: ['ember-metal-views']}, 'ember-routing': {trees: null, vendorRequirements: ['router', 'route-recognizer'], requirements: ['ember-runtime', 'ember-views']}, 'ember-routing-handlebars': {trees: null, requirements: ['ember-routing', 'ember-handlebars']},
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
package.json
@@ -42,7 +42,7 @@ "git-repo-version": "0.0.1", "glob": "~3.2.8", "handlebars": "^2.0", - "htmlbars": "tildeio/htmlbars#e6cfd7517b279de437b93fc2f66775b37c029c5d", + "htmlbars": "0.1.3", "ncp": "~0.5.1", "rimraf": "~2.2.8", "rsvp": "~3.0.6"
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
packages/ember-htmlbars/tests/hooks/text_node_test.js
@@ -2,7 +2,7 @@ import EmberView from "ember-views/views/view"; import run from "ember-metal/run_loop"; import EmberObject from "ember-runtime/system/object"; import { compile } from "htmlbars-compiler/compiler"; -import { equalInnerHTML } from "../helpers"; +import { equalInnerHTML } from "htmlbars-test-helpers"; var view;
true
Other
emberjs
ember.js
f151c5b64bc2446b985777920b3ed9b1a4ff6b1c.json
Use HTMLBars from published NPM package. * Removes need to do crazy monkey patching/nesting inside HTMLBars. * Enables us to use the specific version of simple-html-tokenizer for the version of HTMLBars we are using. * Do not use `htmlbars-runtime` (ember-htmlbars is our runtime). * Use `htmlbars-test-helpers` package instead of grabbing `test/support/`.
packages/ember-htmlbars/tests/htmlbars_test.js
@@ -1,6 +1,6 @@ import { compile } from "htmlbars-compiler/compiler"; import { defaultEnv } from "ember-htmlbars"; -import { equalHTML } from "./helpers"; +import { equalHTML } from "htmlbars-test-helpers"; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
549416bf59908c3844ace759478aca943bbe9496.json
Add HTMLBars component hook. Allows component lookup via: ```javascript <some-thing> Stuff here... </some-thing> ```
packages/ember-htmlbars/lib/hooks.js
@@ -1,3 +1,4 @@ +import Ember from "ember-metal/core"; import { lookupHelper } from "ember-htmlbars/system/lookup-helper"; import { sanitizeOptionsForHelper } from "ember-htmlbars/system/sanitize-for-helper"; @@ -43,6 +44,17 @@ export function content(morph, path, view, params, hash, options, env) { return helper.call(view, params, hash, options, env); } +export function component(morph, tagName, view, hash, options, env) { + var params = []; + var helper = lookupHelper(tagName, view, env); + + Ember.assert('You specified `' + tagName + '` in your template, but a component for `' + tagName + '` could not be found.', !!helper); + + streamifyArgs(view, params, hash, options, env); + sanitizeOptionsForHelper(options); + return helper.call(view, params, hash, options, env); +} + export function element(element, path, view, params, hash, options, env) { //jshint ignore:line var helper = lookupHelper(path, view, env);
true
Other
emberjs
ember.js
549416bf59908c3844ace759478aca943bbe9496.json
Add HTMLBars component hook. Allows component lookup via: ```javascript <some-thing> Stuff here... </some-thing> ```
packages/ember-htmlbars/lib/main.js
@@ -1,5 +1,10 @@ import Ember from "ember-metal/core"; -import { content, element, subexpr } from "ember-htmlbars/hooks"; +import { + content, + element, + subexpr, + component +} from "ember-htmlbars/hooks"; import { DOMHelper } from "morph"; import template from "ember-htmlbars/system/template"; import compile from "ember-htmlbars/system/compile"; @@ -58,7 +63,8 @@ export var defaultEnv = { hooks: { content: content, element: element, - subexpr: subexpr + subexpr: subexpr, + component: component }, helpers: helpers
true
Other
emberjs
ember.js
549416bf59908c3844ace759478aca943bbe9496.json
Add HTMLBars component hook. Allows component lookup via: ```javascript <some-thing> Stuff here... </some-thing> ```
packages/ember-htmlbars/tests/hooks/component_test.js
@@ -0,0 +1,59 @@ +import ComponentLookup from "ember-views/component_lookup"; +import Container from "container"; +import EmberView from "ember-views/views/view"; +import run from "ember-metal/run_loop"; +import compile from "ember-htmlbars/system/compile"; + +var view, container; + +function generateContainer() { + var container = new Container(); + + container.optionsForType('template', { instantiate: false }); + container.register('component-lookup:main', ComponentLookup); + + return container; +} + +function appendView(view) { + run(function() { view.appendTo('#qunit-fixture'); }); +} + +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + +QUnit.module("ember-htmlbars: component hook", { + setup: function() { + container = generateContainer(); + }, + + teardown: function(){ + if (view) { + run(view, view.destroy); + } + } +}); + +test("component is looked up from the container", function() { + container.register('template:components/foo-bar', compile('yippie!')); + + view = EmberView.create({ + container: container, + template: compile("<foo-bar />") + }); + + appendView(view); + + equal(view.$().text(), 'yippie!', 'component was looked up and rendered'); +}); + +test("asserts if component is not found", function() { + view = EmberView.create({ + container: container, + template: compile("<foo-bar />") + }); + + expectAssertion(function() { + appendView(view); + }, 'You specified `foo-bar` in your template, but a component for `foo-bar` could not be found.'); +}); +}
true
Other
emberjs
ember.js
72b16349ed083fd5e40735823dbf7e5d95007166.json
Import only jQuery instead of Ember in ember-views.
packages/ember-views/lib/views/states/in_buffer.js
@@ -1,7 +1,7 @@ import _default from "ember-views/views/states/default"; import EmberError from "ember-metal/error"; -import Ember from "ember-metal/core"; // Ember.assert +import jQuery from "ember-views/system/jquery"; import { create } from "ember-metal/platform"; import merge from "ember-metal/merge"; @@ -19,7 +19,7 @@ merge(inBuffer, { // rerender the view to allow the render method to reflect the // changes. view.rerender(); - return Ember.$(); + return jQuery(); }, // when a view is rendered in a buffer, rerendering it simply
false
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/lib/main.js
@@ -1,5 +1,8 @@ +import Ember from "ember-metal/core"; import { content, element, subexpr } from "ember-htmlbars/hooks"; import { DOMHelper } from "morph"; +import template from "ember-htmlbars/system/template"; +import compile from "ember-htmlbars/system/compile"; import { registerHelper, @@ -42,6 +45,13 @@ registerHelper('template', templateHelper); registerHelper('bind-attr', bindAttrHelper); registerHelper('bindAttr', bindAttrHelperDeprecated); +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + Ember.HTMLBars = { + template: template, + compile: compile + }; +} + export var defaultEnv = { dom: new DOMHelper(),
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/lib/system/compile.js
@@ -0,0 +1,18 @@ +import { compile } from "htmlbars-compiler/compiler"; +import template from "ember-htmlbars/system/template"; + +/** + Uses HTMLBars `compile` function to process a string into a compiled template. + + This is not present in production builds. + + @private + @method template + @param {String} templateString This is the string to be compiled by HTMLBars. +*/ + +export default function(templateString) { + var templateSpec = compile(templateString); + + return template(templateSpec); +}
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/lib/system/template.js
@@ -0,0 +1,15 @@ +/** + Augments the detault precompiled output of an HTMLBars template with + additional information needed by Ember. + + @private + @method template + @param {Function} templateSpec This is the compiled HTMLBars template spec. +*/ + +export default function(templateSpec) { + templateSpec.isTop = true; + templateSpec.isMethod = false; + + return templateSpec; +}
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/bind_attr_test.js
@@ -15,9 +15,7 @@ import { set } from "ember-metal/property_set"; import { default as htmlbarsHelpers } from "ember-htmlbars/helpers"; -import { - compile as htmlbarsCompile -} from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile, helpers; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/bind_test.js
@@ -2,7 +2,7 @@ import EmberView from "ember-views/views/view"; import EmberObject from "ember-runtime/system/object"; import run from "ember-metal/run_loop"; import EmberHandlebars from "ember-handlebars"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; function appendView(view) { run(function() { view.appendTo('#qunit-fixture'); });
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/debug_test.js
@@ -4,7 +4,7 @@ import run from "ember-metal/run_loop"; import EmberView from "ember-views/views/view"; import EmberHandlebars from "ember-handlebars-compiler"; import { logHelper } from "ember-handlebars/helpers/debug"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/if_unless_test.js
@@ -3,7 +3,7 @@ import run from "ember-metal/run_loop"; import EmberView from "ember-views/views/view"; import ObjectProxy from "ember-runtime/system/object_proxy"; import EmberHandlebars from "ember-handlebars"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/loc_test.js
@@ -1,7 +1,7 @@ import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; import EmberHandlebars from 'ember-handlebars-compiler'; -import { compile as htmlbarsCompile } from 'htmlbars-compiler/compiler'; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/partial_test.js
@@ -5,7 +5,7 @@ import jQuery from "ember-views/system/jquery"; var trim = jQuery.trim; import Container from "ember-runtime/system/container"; import EmberHandlebars from "ember-handlebars-compiler"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var MyApp, lookup, view, container; var originalLookup = Ember.lookup;
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/template_test.js
@@ -6,7 +6,7 @@ var trim = jQuery.trim; import Container from "ember-runtime/system/container"; import EmberHandlebars from "ember-handlebars-compiler"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var MyApp, lookup, view, container; var originalLookup = Ember.lookup;
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/view_test.js
@@ -4,7 +4,7 @@ import Container from 'container/container'; import run from "ember-metal/run_loop"; import jQuery from "ember-views/system/jquery"; import EmberHandlebars from "ember-handlebars"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/with_test.js
@@ -9,7 +9,7 @@ import ObjectController from "ember-runtime/controllers/object_controller"; import Container from "ember-runtime/system/container"; // import { A } from "ember-runtime/system/native_array"; import EmberHandlebars from "ember-handlebars"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/helpers/yield_test.js
@@ -14,7 +14,7 @@ import { } from "ember-htmlbars/helpers"; import EmberHandlebars from "ember-handlebars"; -import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; +import htmlbarsCompile from "ember-htmlbars/system/compile"; var compile, helper; if (Ember.FEATURES.isEnabled('ember-htmlbars')) {
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/system/compile_test.js
@@ -0,0 +1,28 @@ +import compile from "ember-htmlbars/system/compile"; +import { + compile as htmlbarsCompile +} from "htmlbars-compiler/compiler"; + +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + +QUnit.module('ember-htmlbars: compile'); + +test('compiles the provided template with htmlbars', function() { + var templateString = "{{foo}} -- {{some-bar blah='foo'}}"; + + var actual = compile(templateString); + var expected = htmlbarsCompile(templateString); + + equal(actual.toString(), expected.toString(), 'compile function matches content with htmlbars compile'); +}); + +test('calls template on the compiled function', function() { + var templateString = "{{foo}} -- {{some-bar blah='foo'}}"; + + var actual = compile(templateString); + + ok(actual.isTop, 'sets isTop via template function'); + ok(actual.isMethod === false, 'sets isMethod via template function'); +}); + +}
true
Other
emberjs
ember.js
7ffbd9ca809bb33bc10f358589439b6c10073042.json
Add template & compile functions for HTMLBars. This provides a central location for any customizations we need to do to the compiled templates from htmlbars-compiler. Things like `isTop` and `isMethod` being set for example. These are obviously, Ember concerns (neither thing really makes sense in HTMLBars). The node-land precompiler should now return the following template: ```javascript export default Ember.HTMLBars.template(/* output from compileSpec */) ```
packages/ember-htmlbars/tests/system/template_test.js
@@ -0,0 +1,23 @@ +import template from "ember-htmlbars/system/template"; + +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + +QUnit.module('ember-htmlbars: template'); + +test('sets `isTop` on the provided function', function() { + function test() { } + + template(test); + + equal(test.isTop, true, 'sets isTop on the provided function'); +}); + +test('sets `isMethod` on the provided function', function() { + function test() { } + + template(test); + + equal(test.isMethod, false, 'sets isMethod on the provided function'); +}); + +}
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
features.json
@@ -20,15 +20,10 @@ }, "debugStatements": [ "Ember.warn", - "emberWarn", "Ember.assert", - "emberAssert", "Ember.deprecate", - "emberDeprecate", "Ember.debug", - "emberDebug", "Ember.Logger.info", - "Ember.runInDebug", - "runInDebug" + "Ember.runInDebug" ] }
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars-compiler/lib/main.js
@@ -10,7 +10,7 @@ @submodule ember-handlebars-compiler */ -import Ember from "ember-metal/core"; +import Ember from "ember-metal/core"; // Ember.assert // ES6Todo: you'll need to import debugger once debugger is es6'd. if (typeof Ember.assert === 'undefined') { Ember.assert = function(){}; } @@ -25,8 +25,6 @@ var objectCreate = Object.create || function(parent) { // set up for circular references later var View, Component; -// ES6Todo: when ember-debug is es6'ed import this. -// var emberAssert = Ember.assert; var Handlebars = (Ember.imports && Ember.imports.Handlebars) || (this && this.Handlebars); if (!Handlebars && typeof require === 'function') { Handlebars = require('handlebars');
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/controls.js
@@ -3,7 +3,6 @@ import TextField from "ember-handlebars/controls/text_field"; import TextArea from "ember-handlebars/controls/text_area"; import Ember from "ember-metal/core"; // Ember.assert -// var emberAssert = Ember.assert; import EmberHandlebars from "ember-handlebars-compiler";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/ext.js
@@ -1,5 +1,4 @@ import Ember from "ember-metal/core"; // Ember.FEATURES, Ember.assert, Ember.Handlebars, Ember.lookup -// var emberAssert = Ember.assert; import { fmt } from "ember-runtime/system/string";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/helpers/collection.js
@@ -4,10 +4,6 @@ */ import Ember from "ember-metal/core"; // Ember.assert, Ember.deprecate - -// var emberAssert = Ember.assert; - // emberDeprecate = Ember.deprecate; - import EmberHandlebars from "ember-handlebars-compiler"; import { IS_BINDING } from "ember-metal/mixin";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/helpers/partial.js
@@ -1,5 +1,4 @@ import Ember from "ember-metal/core"; // Ember.assert -// var emberAssert = Ember.assert; import isNone from 'ember-metal/is_none'; import { bind } from "ember-handlebars/helpers/binding";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/helpers/view.js
@@ -4,7 +4,6 @@ */ import Ember from "ember-metal/core"; // Ember.warn, Ember.assert -// var emberWarn = Ember.warn, emberAssert = Ember.assert; import EmberObject from "ember-runtime/system/object"; import { get } from "ember-metal/property_get";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-handlebars/lib/helpers/yield.js
@@ -3,8 +3,7 @@ @submodule ember-handlebars */ -import Ember from "ember-metal/core"; -// var emberAssert = Ember.assert; +import Ember from "ember-metal/core"; // Ember.assert import { get } from "ember-metal/property_get";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-htmlbars/lib/helpers/view.js
@@ -4,7 +4,6 @@ */ import Ember from "ember-metal/core"; // Ember.warn, Ember.assert -// var emberWarn = Ember.warn, emberAssert = Ember.assert; import EmberObject from "ember-runtime/system/object"; import { get } from "ember-metal/property_get";
true
Other
emberjs
ember.js
09e137582b7dcd550c350011478aaf0152e87678.json
Remove old debugStatements.
packages/ember-htmlbars/lib/helpers/yield.js
@@ -4,7 +4,6 @@ */ import Ember from "ember-metal/core"; -// var emberAssert = Ember.assert; import { get } from "ember-metal/property_get";
true
Other
emberjs
ember.js
22f33c845bd8c651aac06d7ad663d097fe1a412c.json
Fix version constraint in composer.json
config/package_manager_files/composer.json
@@ -4,7 +4,7 @@ "type": "component", "license": "MIT", "require": { - "components/jquery": ">=1.7.0 <= 2.1.0", + "components/jquery": ">=1.7.0, <= 2.1.0", "components/handlebars.js": "2.*" }, "extra": {
false
Other
emberjs
ember.js
f3245cb111a495c413e0f346e0af3fcc754a7674.json
Add {{debugger}} helper.
packages/ember-htmlbars/lib/helpers/debugger.js
@@ -0,0 +1,51 @@ +/*jshint debug:true*/ + +/** +@module ember +@submodule ember-handlebars +*/ +import Logger from "ember-metal/logger"; + +/** + Execute the `debugger` statement in the current context. + + ```handlebars + {{debugger}} + ``` + + Before invoking the `debugger` statement, there + are a few helpful variables defined in the + body of this helper that you can inspect while + debugging that describe how and where this + helper was invoked: + + - templateContext: this is most likely a controller + from which this template looks up / displays properties + - typeOfTemplateContext: a string description of + what the templateContext is + + For example, if you're wondering why a value `{{foo}}` + isn't rendering as expected within a template, you + could place a `{{debugger}}` statement, and when + the `debugger;` breakpoint is hit, you can inspect + `templateContext`, determine if it's the object you + expect, and/or evaluate expressions in the console + to perform property lookups on the `templateContext`: + + ``` + > templateContext.get('foo') // -> "<value of {{foo}}>" + ``` + + @method debugger + @for Ember.Handlebars.helpers + @param {String} property +*/ +export function debuggerHelper(options) { + + // These are helpful values you can inspect while debugging. + /* jshint unused: false */ + var view = this; + Logger.info('Use `this` to access the view context.'); + + debugger; +}
true
Other
emberjs
ember.js
f3245cb111a495c413e0f346e0af3fcc754a7674.json
Add {{debugger}} helper.
packages/ember-htmlbars/lib/main.js
@@ -10,6 +10,7 @@ import { viewHelper } from "ember-htmlbars/helpers/view"; import { yieldHelper } from "ember-htmlbars/helpers/yield"; import { withHelper } from "ember-htmlbars/helpers/with"; import { logHelper } from "ember-htmlbars/helpers/log"; +import { debuggerHelper } from "ember-htmlbars/helpers/debugger"; import { ifHelper, unlessHelper, @@ -27,6 +28,7 @@ registerHelper('unless', unlessHelper); registerHelper('unboundIf', unboundIfHelper); registerHelper('boundIf', boundIfHelper); registerHelper('log', logHelper); +registerHelper('debugger', debuggerHelper); export var defaultEnv = { dom: new DOMHelper(),
true
Other
emberjs
ember.js
5abb7216a4de440e744623bf19d0ca2a391e72f7.json
Add {{log}} helper to HTMLBars.
packages/ember-htmlbars/lib/helpers/log.js
@@ -0,0 +1,33 @@ +/** +@module ember +@submodule ember-handlebars +*/ +import Logger from "ember-metal/logger"; + +/** + `log` allows you to output the value of variables in the current rendering + context. `log` also accepts primitive types such as strings or numbers. + + ```handlebars + {{log "myVariable:" myVariable }} + ``` + + @method log + @for Ember.Handlebars.helpers + @param {String} property +*/ +export function logHelper(params, options, env) { + var logger = Logger.log; + var values = []; + + for (var i = 0; i < params.length; i++) { + if (options.types[i] === 'id') { + var stream = params[i]; + values.push(stream.value()); + } else { + values.push(params[i]); + } + } + + logger.apply(logger, values); +}
true
Other
emberjs
ember.js
5abb7216a4de440e744623bf19d0ca2a391e72f7.json
Add {{log}} helper to HTMLBars.
packages/ember-htmlbars/lib/main.js
@@ -9,6 +9,7 @@ import { bindHelper } from "ember-htmlbars/helpers/binding"; import { viewHelper } from "ember-htmlbars/helpers/view"; import { yieldHelper } from "ember-htmlbars/helpers/yield"; import { withHelper } from "ember-htmlbars/helpers/with"; +import { logHelper } from "ember-htmlbars/helpers/log"; import { ifHelper, unlessHelper, @@ -25,6 +26,7 @@ registerHelper('if', ifHelper); registerHelper('unless', unlessHelper); registerHelper('unboundIf', unboundIfHelper); registerHelper('boundIf', boundIfHelper); +registerHelper('log', logHelper); export var defaultEnv = { dom: new DOMHelper(),
true
Other
emberjs
ember.js
5abb7216a4de440e744623bf19d0ca2a391e72f7.json
Add {{log}} helper to HTMLBars.
packages/ember-htmlbars/tests/helpers/debug_test.js
@@ -4,6 +4,14 @@ import run from "ember-metal/run_loop"; import EmberView from "ember-views/views/view"; import EmberHandlebars from "ember-handlebars-compiler"; import { logHelper } from "ember-handlebars/helpers/debug"; +import { compile as htmlbarsCompile } from "htmlbars-compiler/compiler"; + +var compile; +if (Ember.FEATURES.isEnabled('ember-htmlbars')) { + compile = htmlbarsCompile; +} else { + compile = EmberHandlebars.compile; +} var originalLookup = Ember.lookup; var lookup; @@ -49,7 +57,7 @@ test("should be able to log multiple properties", function() { view = EmberView.create({ context: context, - template: EmberHandlebars.compile('{{log value valueTwo}}') + template: compile('{{log value valueTwo}}') }); appendView(); @@ -67,7 +75,7 @@ test("should be able to log primitives", function() { view = EmberView.create({ context: context, - template: EmberHandlebars.compile('{{log value "foo" 0 valueTwo true}}') + template: compile('{{log value "foo" 0 valueTwo true}}') }); appendView();
true
Other
emberjs
ember.js
d8b99791ab6c32d6cc864812fa88a1efddf39510.json
Fix typo in test name
packages/ember-metal/tests/computed_test.js
@@ -388,7 +388,7 @@ testBoth('circular keys should not blow up', function(get, set) { equal(get(obj, 'foo'), 'foo 3', 'cached retrieve'); }); -testBoth('redefining a property should undo old depenent keys', function(get ,set) { +testBoth('redefining a property should undo old dependent keys', function(get ,set) { equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key'); equal(get(obj, 'foo'), 'bar 1');
false
Other
emberjs
ember.js
8fc24566fdc7c4a94d5b6a3991262200b98b09c4.json
Move WithView to ember-views
packages/ember-handlebars/lib/helpers/with.js
@@ -5,58 +5,10 @@ import Ember from "ember-metal/core"; // Ember.assert -import { set } from "ember-metal/property_set"; -import { apply } from "ember-metal/utils"; import { create as o_create } from "ember-metal/platform"; import isNone from 'ember-metal/is_none'; import { bind } from "ember-handlebars/helpers/binding"; -import { _HandlebarsBoundView } from "ember-handlebars/views/handlebars_bound_view"; - -function exists(value) { - return !isNone(value); -} - -var WithView = _HandlebarsBoundView.extend({ - init: function() { - apply(this, this._super, arguments); - - var keywordName = this.templateHash.keywordName; - var controllerName = this.templateHash.controller; - - if (controllerName) { - var previousContext = this.previousContext; - var controller = this.container.lookupFactory('controller:'+controllerName).create({ - parentController: previousContext, - target: previousContext - }); - - this._generatedController = controller; - - if (this.preserveContext) { - this._keywords[keywordName] = controller; - this.lazyValue.subscribe(function(modelStream) { - set(controller, 'model', modelStream.value()); - }); - } else { - set(this, 'controller', controller); - this.valueNormalizerFunc = function(result) { - controller.set('model', result); - return controller; - }; - } - - set(controller, 'model', this.lazyValue.value()); - } - }, - - willDestroy: function() { - this._super(); - - if (this._generatedController) { - this._generatedController.destroy(); - } - } -}); +import WithView from "ember-views/views/with_view"; /** Use the `{{with}}` helper when you want to scope context. Take the following code as an example: @@ -178,3 +130,7 @@ export default function withHelper(contextPath) { return bind.call(bindContext, contextPath, options, preserveContext, exists, undefined, undefined, WithView); } + +function exists(value) { + return !isNone(value); +}
true
Other
emberjs
ember.js
8fc24566fdc7c4a94d5b6a3991262200b98b09c4.json
Move WithView to ember-views
packages/ember-htmlbars/lib/helpers/with.js
@@ -5,58 +5,10 @@ import Ember from "ember-metal/core"; // Ember.assert -import { set } from "ember-metal/property_set"; -import { apply } from "ember-metal/utils"; import { create as o_create } from "ember-metal/platform"; import isNone from 'ember-metal/is_none'; import { bind } from "ember-htmlbars/helpers/binding"; -import { _HandlebarsBoundView } from "ember-handlebars/views/handlebars_bound_view"; - -function exists(value) { - return !isNone(value); -} - -var WithView = _HandlebarsBoundView.extend({ - init: function() { - apply(this, this._super, arguments); - - var keywordName = this.templateHash.keywordName; - var controllerName = this.templateHash.controller; - - if (controllerName) { - var previousContext = this.previousContext; - var controller = this.container.lookupFactory('controller:'+controllerName).create({ - parentController: previousContext, - target: previousContext - }); - - this._generatedController = controller; - - if (this.preserveContext) { - this._keywords[keywordName] = controller; - this.lazyValue.subscribe(function(modelStream) { - set(controller, 'model', modelStream.value()); - }); - } else { - set(this, 'controller', controller); - this.valueNormalizerFunc = function(result) { - controller.set('model', result); - return controller; - }; - } - - set(controller, 'model', this.lazyValue.value()); - } - }, - - willDestroy: function() { - this._super(); - - if (this._generatedController) { - this._generatedController.destroy(); - } - } -}); +import WithView from "ember-views/views/with_view"; /** Use the `{{with}}` helper when you want to scope context. Take the following code as an example: @@ -169,3 +121,7 @@ export function withHelper(params, options, env) { bind.call(this, source, options, env, preserveContext, exists, undefined, undefined, WithView); } + +function exists(value) { + return !isNone(value); +}
true
Other
emberjs
ember.js
8fc24566fdc7c4a94d5b6a3991262200b98b09c4.json
Move WithView to ember-views
packages/ember-views/lib/views/with_view.js
@@ -0,0 +1,51 @@ + +/** +@module ember +@submodule ember-views +*/ + +import { set } from "ember-metal/property_set"; +import { apply } from "ember-metal/utils"; +import { _HandlebarsBoundView } from "ember-handlebars/views/handlebars_bound_view"; + +export default _HandlebarsBoundView.extend({ + init: function() { + apply(this, this._super, arguments); + + var keywordName = this.templateHash.keywordName; + var controllerName = this.templateHash.controller; + + if (controllerName) { + var previousContext = this.previousContext; + var controller = this.container.lookupFactory('controller:'+controllerName).create({ + parentController: previousContext, + target: previousContext + }); + + this._generatedController = controller; + + if (this.preserveContext) { + this._keywords[keywordName] = controller; + this.lazyValue.subscribe(function(modelStream) { + set(controller, 'model', modelStream.value()); + }); + } else { + set(this, 'controller', controller); + this.valueNormalizerFunc = function(result) { + controller.set('model', result); + return controller; + }; + } + + set(controller, 'model', this.lazyValue.value()); + } + }, + + willDestroy: function() { + this._super(); + + if (this._generatedController) { + this._generatedController.destroy(); + } + } +});
true
Other
emberjs
ember.js
9f32ac807b0e32f242d8960df80dadc77f65ab96.json
Restore apply as a fallback
packages/ember-metal/lib/logger.js
@@ -19,6 +19,12 @@ function consoleMethod(name) { logToConsole = method.bind(consoleObj); logToConsole.displayName = 'console.' + name; return logToConsole; + } else if (typeof method.apply === 'function') { + logToConsole = function() { + method.apply(consoleObj, arguments); + }; + logToConsole.displayName = 'console.' + name; + return logToConsole; } else { return function() { var message = Array.prototype.join.call(arguments, ', ');
false
Other
emberjs
ember.js
cbf58a8292254ec75d430986868e695b0028934c.json
Publish test index.html for easier testing from S3.
Brocfile.js
@@ -249,6 +249,45 @@ testConfig = replace(testConfig, { ] }); +var s3TestRunner = pickFiles(testConfig, { + srcDir: '/tests', + destDir: '/ember-tests', + files: ['index.html'] +}); + +s3TestRunner = replace(s3TestRunner, { + files: ['ember-tests/index.html'], + patterns: [ + { match: new RegExp('../ember', 'g'), replacement: './ember' }, + { match: new RegExp('../qunit/qunit.css', 'g'), replacement: 'http://code.jquery.com/qunit/qunit-1.15.0.css' }, + { match: new RegExp('../qunit/qunit.js', 'g'), replacement: 'http://code.jquery.com/qunit/qunit-1.15.0.js' }, + { match: new RegExp('../handlebars/handlebars.js', 'g'), replacement: 'http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js' }, + { match: new RegExp('../jquery/jquery.js', 'g'), replacement: 'http://code.jquery.com/jquery-1.11.1.js'} + ] +}); + +testConfig = replace(testConfig, { + files: [ 'tests/index.html' ], + patterns: [ + { match: /\{\{DEV_FEATURES\}\}/g, + replacement: function() { + var features = defeatureifyConfig().enabled; + + return JSON.stringify(features); + } + }, + { match: /\{\{PROD_FEATURES\}\}/g, + replacement: function() { + var features = defeatureifyConfig({ + environment: 'production' + }).enabled; + + return JSON.stringify(features); + } + }, + ] +}); + // List of bower component trees that require no special handling. These will // be included in the distTrees for use within testsConfig/index.html var bowerFiles = [ @@ -727,6 +766,7 @@ var distTrees = [templateCompilerTree, compiledSource, compiledTests, testingCom // This ensures development build speed is not affected by unnecessary // minification and defeaturification if (env !== 'development') { + distTrees.push(s3TestRunner); distTrees.push(prodCompiledSource); distTrees.push(prodCompiledTests);
true
Other
emberjs
ember.js
cbf58a8292254ec75d430986868e695b0028934c.json
Publish test index.html for easier testing from S3.
config/s3ProjectConfig.js
@@ -1,12 +1,13 @@ fileMap = function(revision,tag,date) { return { "ember.js": fileObject("ember", ".js", "text/javascript", revision, tag, date), - "ember-tests.js": fileObject("ember-test", ".js", "text/javascript", revision, tag, date), + "ember-tests.js": fileObject("ember-tests", ".js", "text/javascript", revision, tag, date), "ember-template-compiler.js": fileObject("ember-template-compiler", ".js", "text/javascript", revision, tag, date), "ember-runtime.js": fileObject("ember-runtime", ".js", "text/javascript", revision, tag, date), "ember.min.js": fileObject("ember.min", ".js", "text/javascript", revision, tag, date), "ember.prod.js": fileObject("ember.prod", ".js", "text/javascript", revision, tag, date), - "../docs/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date) + "../docs/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date), + "ember-tests/index.html": fileObject("ember-tests-index", ".html", "text/html", revision, tag, date) }; }; @@ -16,7 +17,6 @@ function fileObject(baseName, extension, contentType, currentRevision, tag, date contentType: contentType, destinations: { canary: [ - baseName + "-latest" + extension, "latest" + fullName, "canary" + fullName, "canary/daily/" + date + fullName,
true
Other
emberjs
ember.js
8a895e1b9559dfd846bdeb332dea12cb8279aa87.json
Use bind instead of apply in logger
packages/ember-metal/lib/logger.js
@@ -14,11 +14,9 @@ function consoleMethod(name) { var method = typeof consoleObj === 'object' ? consoleObj[name] : null; if (method) { - // Older IE doesn't support apply, but Chrome needs it - if (typeof method.apply === 'function') { - logToConsole = function() { - method.apply(consoleObj, arguments); - }; + // Older IE doesn't support bind, but Chrome needs it + if (typeof method.bind === 'function') { + logToConsole = method.bind(consoleObj); logToConsole.displayName = 'console.' + name; return logToConsole; } else {
false
Other
emberjs
ember.js
880d7f3a47fb29902eae5f32258a081421a639c0.json
Serve documentation live from /docs endpont
Brocfile.js
@@ -18,6 +18,7 @@ var useStrictRemover = require('broccoli-use-strict-remover'); var derequire = require('broccoli-derequire'); var getVersion = require('git-repo-version'); +var yuidocPlugin = require('ember-cli-yuidoc'); // To create fast production builds (without ES3 support, minification, derequire, or JSHint) // run the following: @@ -28,6 +29,7 @@ var env = process.env.EMBER_ENV || 'development'; var disableJSHint = !!process.env.DISABLE_JSHINT || false; var disableES3 = !!process.env.DISABLE_ES3 || false; var disableMin = !!process.env.DISABLE_MIN || false; +var enableDocs = !!process.env.ENABLE_DOCS || false; var disableDefeatureify; var disableDerequire = !!process.env.DISABLE_DEREQUIRE || false; @@ -730,6 +732,11 @@ if (env !== 'development') { // merge distTrees and sub out version placeholders for distribution distTrees = mergeTrees(distTrees); + +if (enableDocs && process.argv[2] === "serve") { + distTrees = yuidocPlugin.addDocsToTree(distTrees); +} + distTrees = replace(distTrees, { files: [ '**/*.js', '**/*.json' ], patterns: [
true
Other
emberjs
ember.js
880d7f3a47fb29902eae5f32258a081421a639c0.json
Serve documentation live from /docs endpont
package.json
@@ -35,7 +35,7 @@ "chalk": "~0.4.0", "defeatureify": "~0.2.0", "ember-cli": "0.0.46", - "ember-cli-yuidoc": "0.1.1", + "ember-cli-yuidoc": "0.3.1", "ember-publisher": "0.0.6", "es6-module-transpiler": "~0.4.0", "express": "^4.5.0",
true
Other
emberjs
ember.js
1a14916e45c69dac52773db36ec880ba129394a7.json
Add 1.8.1 to CHANGELOG.
CHANGELOG.md
@@ -4,6 +4,15 @@ * [BREAKING] Require Handlebars 2.0. See [blog post](http://emberjs.com/blog/2014/10/16/handlebars-update.html) for details. +### Ember 1.8.1 (November, 4, 2014) + +* [BUGFIX] Make sure that `{{view}}` can accept a Ember.View instance. +* [BUGFIX] Throw an assertion if `classNameBindings` are specified on a tag-less view. +* [BUGFIX] Setting an `attributeBinding` for `class` attribute triggers assertion. +* [BUGFIX] Fix `htmlSafe` to allow non-strings in unescaped code. +* [BUGFIX] Add support for null prototype object to mandatory setter code. Prevents errors when operating on Ember Data `meta` objects. +* [BUGFIX] Fix an issue with select/each that causes the last item rendered to be selected. + ### Ember 1.8.0 (October, 28, 2014) * [BUGFIX] Ensure published builds do not use `define` or `require` internally.
false
Other
emberjs
ember.js
322fc0e371a6df88c1c29d80db8cb545be5315a8.json
Allow all rejection types. In `RSVP.onerrorDefault` we only handled `instanceof Error`, but we really only care about ignoring `TransitionAborted` (because that is the only acceptable rejection).
packages/ember-runtime/lib/ext/rsvp.js
@@ -42,7 +42,7 @@ RSVP.Promise.prototype.fail = function(callback, label){ }; RSVP.onerrorDefault = function (error) { - if (error instanceof Error) { + if (error && error.name !== 'TransitionAborted') { if (Ember.testing) { // ES6TODO: remove when possible if (!Test && Ember.__loader.registry[testModuleName]) {
true
Other
emberjs
ember.js
322fc0e371a6df88c1c29d80db8cb545be5315a8.json
Allow all rejection types. In `RSVP.onerrorDefault` we only handled `instanceof Error`, but we really only care about ignoring `TransitionAborted` (because that is the only acceptable rejection).
packages/ember-runtime/tests/ext/rsvp_test.js
@@ -108,3 +108,12 @@ test("given `Ember.testing = true`, correctly informs the test suite about async equal(asyncEnded, 2); }); }); + +test('TransitionAborted errors are not re-thrown', function() { + expect(1); + var fakeTransitionAbort = { name: 'TransitionAborted' }; + + run(RSVP, 'reject', fakeTransitionAbort); + + ok(true, 'did not throw an error when dealing with TransitionAborted'); +});
true
Other
emberjs
ember.js
322fc0e371a6df88c1c29d80db8cb545be5315a8.json
Allow all rejection types. In `RSVP.onerrorDefault` we only handled `instanceof Error`, but we really only care about ignoring `TransitionAborted` (because that is the only acceptable rejection).
packages/ember-runtime/tests/mixins/promise_proxy_test.js
@@ -244,15 +244,20 @@ test("should have content when isFulfilled is set", function() { }); test("should have reason when isRejected is set", function() { + var error = new Error('Y U REJECT?!?'); var deferred = EmberRSVP.defer(); var proxy = ObjectPromiseProxy.create({ promise: deferred.promise }); proxy.addObserver('isRejected', function() { - equal(get(proxy, 'reason'), true); + equal(get(proxy, 'reason'), error); }); - run(deferred, 'reject', true); + try { + run(deferred, 'reject', error); + } catch(e) { + equal(e, error); + } });
true
Other
emberjs
ember.js
cdfc3519d0e4be30ee6e5ef40aaa078f26f2f603.json
Fix old comments
packages/ember-runtime/tests/system/object/reopen_test.js
@@ -30,8 +30,7 @@ test('reopened properties inherited by subclasses', function() { equal(get(new SubSub(), 'bar'), 'BAR', 'Adds property'); }); -// We plan to allow this in the future -test('does not allow reopening already instantiated classes', function() { +test('allows reopening already instantiated classes', function() { var Subclass = EmberObject.extend(); Subclass.create();
false
Other
emberjs
ember.js
f4f2699bf732033747eeaa16f39ec85d619b32fe.json
Fix old comments
packages/ember-routing-handlebars/tests/helpers/action_test.js
@@ -1,4 +1,4 @@ -import Ember from 'ember-metal/core'; // A, FEATURES, assert, TESTING_DEPRECATION +import Ember from 'ember-metal/core'; // A, FEATURES, assert import { set } from "ember-metal/property_set"; import run from "ember-metal/run_loop"; import EventDispatcher from "ember-views/system/event_dispatcher";
true
Other
emberjs
ember.js
f4f2699bf732033747eeaa16f39ec85d619b32fe.json
Fix old comments
packages/ember-views/tests/system/event_dispatcher_test.js
@@ -1,4 +1,4 @@ -import Ember from 'ember-metal/core'; // A, FEATURES, assert, TESTING_DEPRECATION +import Ember from 'ember-metal/core'; // A, FEATURES, assert import { get } from "ember-metal/property_get"; import run from "ember-metal/run_loop";
true
Other
emberjs
ember.js
3d4e0e3474d1a4a42988032cae68b228a1ee1452.json
Add test for errors thrown in andThen.
packages/ember-testing/tests/acceptance_test.js
@@ -262,6 +262,22 @@ test("Unhandled exceptions are logged via Ember.Test.adapter#exception", functio asyncHandled = click(".does-not-exist"); }); +test("Unhandled exceptions in `andThen` are logged via Ember.Test.adapter#exception", function () { + expect(1); + + Test.adapter = QUnitAdapter.create({ + exception: function(error) { + equal(error.message, "Catch me", "Exception successfully caught and passed to Ember.Test.adapter.exception"); + } + }); + + visit('/posts'); + + andThen(function() { + throw new Error('Catch me'); + }); +}); + test("should not start routing on the root URL when visiting another", function(){ visit('/posts');
false
Other
emberjs
ember.js
a6b9d76ee4acf0cb23107af3fb7d2edbb73e8154.json
Fix path of data.json
config/s3ProjectConfig.js
@@ -6,7 +6,7 @@ fileMap = function(revision,tag,date) { "ember-runtime.js": fileObject("ember-runtime", ".js", "text/javascript", revision, tag, date), "ember.min.js": fileObject("ember.min", ".js", "text/javascript", revision, tag, date), "ember.prod.js": fileObject("ember.prod", ".js", "text/javascript", revision, tag, date), -// "../docs/build/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date) + "../docs/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date) }; };
false
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-handlebars/lib/helpers/partial.js
@@ -1,7 +1,7 @@ import Ember from "ember-metal/core"; // Ember.assert // var emberAssert = Ember.assert; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import { bind } from "ember-handlebars/helpers/binding"; /**
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-metal/lib/computed.js
@@ -1,4 +1,3 @@ -import Ember from "ember-metal/core"; import { set } from "ember-metal/property_set"; import { meta,
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-metal/lib/computed_macros.js
@@ -3,7 +3,7 @@ import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; import { computed } from "ember-metal/computed"; import isEmpty from 'ember-metal/is_empty'; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import alias from 'ember-metal/alias'; /**
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-metal/lib/is_empty.js
@@ -1,4 +1,3 @@ -import Ember from 'ember-metal/core'; // deprecateFunc import { get } from 'ember-metal/property_get'; import isNone from 'ember-metal/is_none'; @@ -57,10 +56,4 @@ function isEmpty(obj) { return false; } -var empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", isEmpty); - export default isEmpty; -export { - isEmpty, - empty -};
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-metal/lib/is_none.js
@@ -1,5 +1,3 @@ -import Ember from 'ember-metal/core'; // deprecateFunc - /** Returns true if the passed value is null or undefined. This avoids errors from JSLint complaining about use of ==, which can be technically @@ -23,7 +21,4 @@ function isNone(obj) { return obj === null || obj === undefined; } -export var none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", isNone); - export default isNone; -export { isNone };
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-metal/lib/main.js
@@ -161,14 +161,8 @@ import { } from "ember-metal/binding"; import run from "ember-metal/run_loop"; import libraries from "ember-metal/libraries"; -import { - isNone, - none -} from 'ember-metal/is_none'; -import { - isEmpty, - empty -} from 'ember-metal/is_empty'; +import isNone from 'ember-metal/is_none'; +import isEmpty from 'ember-metal/is_empty'; import isBlank from 'ember-metal/is_blank'; import isPresent from 'ember-metal/is_present'; import keys from 'ember-metal/keys'; @@ -321,11 +315,7 @@ Ember.libraries = libraries; Ember.libraries.registerCoreLibrary('Ember', Ember.VERSION); Ember.isNone = isNone; -Ember.none = none; - Ember.isEmpty = isEmpty; -Ember.empty = empty; - Ember.isBlank = isBlank; if (Ember.FEATURES.isEnabled('ember-metal-is-present')) {
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-routing/lib/system/route.js
@@ -7,7 +7,7 @@ import { forEach, replace }from "ember-metal/enumerable_utils"; -import { isNone } from "ember-metal/is_none"; +import isNone from "ember-metal/is_none"; import { computed } from "ember-metal/computed"; import merge from "ember-metal/merge"; import {
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-runtime/lib/mixins/array.js
@@ -13,9 +13,7 @@ import { computed, cacheFor } from 'ember-metal/computed'; -import { - isNone -} from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import Enumerable from 'ember-runtime/mixins/enumerable'; import { map } from 'ember-metal/enumerable_utils'; import {
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-runtime/lib/mixins/observable.js
@@ -27,7 +27,7 @@ import { observersFor } from "ember-metal/observer"; import { cacheFor } from "ember-metal/computed"; -import { isNone } from "ember-metal/is_none"; +import isNone from "ember-metal/is_none"; var slice = Array.prototype.slice;
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-runtime/lib/system/set.js
@@ -7,7 +7,7 @@ import Ember from "ember-metal/core"; // Ember.isNone, Ember.A import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; import { guidFor } from "ember-metal/utils"; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import { fmt } from "ember-runtime/system/string"; import CoreObject from "ember-runtime/system/core_object"; import MutableEnumerable from "ember-runtime/mixins/mutable_enumerable";
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-runtime/tests/core/is_empty_test.js
@@ -1,5 +1,5 @@ import Ember from "ember-metal/core"; -import {isEmpty} from 'ember-metal/is_empty'; +import isEmpty from 'ember-metal/is_empty'; import ArrayProxy from "ember-runtime/system/array_proxy"; QUnit.module("Ember.isEmpty");
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-runtime/tests/legacy_1x/system/set_test.js
@@ -1,5 +1,5 @@ import Ember from "ember-metal/core"; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import Set from "ember-runtime/system/set"; import EmberObject from 'ember-runtime/system/object'; import EmberArray from "ember-runtime/mixins/array";
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-views/lib/system/event_dispatcher.js
@@ -6,7 +6,7 @@ import Ember from "ember-metal/core"; // Ember.assert import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import run from "ember-metal/run_loop"; import { typeOf } from "ember-metal/utils"; import { fmt } from "ember-runtime/system/string";
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-views/lib/views/component.js
@@ -6,7 +6,7 @@ import View from "ember-views/views/view"; import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import { computed } from "ember-metal/computed";
true
Other
emberjs
ember.js
b98b1ff7084c051fad8a2c03b504dbd6c644940e.json
Remove Ember.empty and Ember.none. These have been deprecated since before 1.0.0, and serve no purpose now.
packages/ember-views/lib/views/view.js
@@ -26,7 +26,7 @@ import { typeOf, isArray } from "ember-metal/utils"; -import { isNone } from 'ember-metal/is_none'; +import isNone from 'ember-metal/is_none'; import { Mixin } from 'ember-metal/mixin'; import { deprecateProperty } from "ember-metal/deprecate_property"; import { A as emberA } from "ember-runtime/system/native_array";
true
Other
emberjs
ember.js
6db588073bbe1997480f6740f081b8b81cafbcd0.json
Add better labels to tests, reorder
packages/ember-runtime/tests/core/compare_test.js
@@ -57,11 +57,11 @@ test('comparables should return values in the range of -1, 0, 1', function() { var zero = Comp.create({ val: 0 }); var one = Comp.create({ val: 1 }); - equal(compare('a', negOne), 1, 'Second item comparable - Should return valid range -1, 0, 1'); - equal(compare('b', zero), 0, 'Second item comparable - Should return valid range -1, 0, 1'); - equal(compare('c', one), -1, 'Second item comparable - Should return valid range -1, 0, 1'); + equal(compare(negOne, 'a'), -1, 'First item comparable - returns -1 (not negated)'); + equal(compare(zero, 'b'), 0, 'First item comparable - returns 0 (not negated)'); + equal(compare(one, 'c'), 1, 'First item comparable - returns 1 (not negated)'); - equal(compare(negOne, 'a'), -1, 'First itam comparable - Should return valid range -1, 0, 1'); - equal(compare(zero, 'b'), 0, 'First itam comparable - Should return valid range -1, 0, 1'); - equal(compare(one, 'c'), 1, 'First itam comparable - Should return valid range -1, 0, 1'); + equal(compare('a', negOne), 1, 'Second item comparable - returns -1 (negated)'); + equal(compare('b', zero), 0, 'Second item comparable - returns 0 (negated)'); + equal(compare('c', one), -1, 'Second item comparable - returns 1 (negated)'); });
false
Other
emberjs
ember.js
ca94affbe1c3bc45583c04167a20e9328580c215.json
Fix publishing of canary builds.
config/s3ProjectConfig.js
@@ -6,7 +6,7 @@ fileMap = function(revision,tag,date) { "ember-runtime.js": fileObject("ember-runtime", ".js", "text/javascript", revision, tag, date), "ember.min.js": fileObject("ember.min", ".js", "text/javascript", revision, tag, date), "ember.prod.js": fileObject("ember.prod", ".js", "text/javascript", revision, tag, date), - "../docs/build/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date) +// "../docs/build/data.json": fileObject("ember-docs", ".json", "application/json", revision, tag, date) }; };
false
Other
emberjs
ember.js
61ef73d2e922fa3a053aee77f3b3172c8e9aa5d2.json
Fix jQuery dependency in component.json The jQuery dependency in component.json is pointing at the wrong repository. This causes component and duo to fail when they try to install `components/ember`. Changing the dependency from `component/jquery` to `components/jquery` fixes the problem.
config/package_manager_files/component.json
@@ -7,7 +7,7 @@ "ember.js" ], "dependencies": { - "component/jquery": ">= 1.7.0 <= 2.1.0", + "components/jquery": ">= 1.7.0 <= 2.1.0", "components/handlebars.js": ">= 2.0.0 < 3.0.0" } }
false
Other
emberjs
ember.js
89da7c29a1a46c9fd31b1c68f44ad77310139d20.json
Add API to get a view's client rects
packages/ember-views/lib/main.js
@@ -11,7 +11,9 @@ Ember Views import Ember from "ember-runtime"; import jQuery from "ember-views/system/jquery"; import { - isSimpleClick + isSimpleClick, + getViewClientRects, + getViewBoundingClientRect } from "ember-views/system/utils"; import RenderBuffer from "ember-views/system/render_buffer"; import "ember-views/system/ext"; // for the side effect of extending Ember.run.queues @@ -20,8 +22,8 @@ import { states } from "ember-views/views/states"; -import CoreView from "ember-views/views/core_view"; -import View from "ember-views/views/view"; +import CoreView from "ember-views/views/core_view"; +import View from "ember-views/views/view"; import ContainerView from "ember-views/views/container_view"; import CollectionView from "ember-views/views/collection_view"; import Component from "ember-views/views/component"; @@ -45,6 +47,8 @@ Ember.RenderBuffer = RenderBuffer; var ViewUtils = Ember.ViewUtils = {}; ViewUtils.isSimpleClick = isSimpleClick; +ViewUtils.getViewClientRects = getViewClientRects; +ViewUtils.getViewBoundingClientRect = getViewBoundingClientRect; Ember.CoreView = CoreView; Ember.View = View;
true
Other
emberjs
ember.js
89da7c29a1a46c9fd31b1c68f44ad77310139d20.json
Add API to get a view's client rects
packages/ember-views/lib/system/utils.js
@@ -9,3 +9,47 @@ export function isSimpleClick(event) { return !modifier && !secondaryClick; } + +/** + @private + @method getViewRange + @param {Ember.View} view +*/ +function getViewRange(view) { + var range = document.createRange(); + range.setStartAfter(view._morph.start); + range.setEndBefore(view._morph.end); + return range; +} + +/** + `getViewClientRects` provides information about the position of the border + box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inpsector + and may not work on older browsers. + + @private + @method getViewClientRects + @param {Ember.View} view +*/ +export function getViewClientRects(view) { + var range = getViewRange(view); + return range.getClientRects(); +} + +/** + `getViewBoundingClientRect` provides information about the position of the + bounding border box edges of a view relative to the viewport. + + It is only intended to be used by development tools like the Ember Inpsector + and may not work on older browsers. + + @private + @method getViewBoundingClientRect + @param {Ember.View} view +*/ +export function getViewBoundingClientRect(view) { + var range = getViewRange(view); + return range.getBoundingClientRect(); +}
true
Other
emberjs
ember.js
89da7c29a1a46c9fd31b1c68f44ad77310139d20.json
Add API to get a view's client rects
packages/ember-views/tests/system/view_utils_test.js
@@ -0,0 +1,46 @@ +import run from "ember-metal/run_loop"; +import View from "ember-views/views/view"; + +var view; + +QUnit.module("ViewUtils", { + teardown: function() { + run(function() { + if (view) { view.destroy(); } + }); + } +}); + +test("getViewClientRects", function() { + if (!(window.Range && window.Range.prototype.getClientRects)) { + ok(true, "The test environment does not support the DOM API required for getViewClientRects."); + return; + } + + view = View.create({ + render: function(buffer) { + buffer.push("Hello, world!"); + } + }); + + run(function() { view.appendTo('#qunit-fixture'); }); + + ok(Ember.ViewUtils.getViewClientRects(view) instanceof window.ClientRectList); +}); + +test("getViewBoundingClientRect", function() { + if (!(window.Range && window.Range.prototype.getBoundingClientRect)) { + ok(true, "The test environment does not support the DOM API required for getViewBoundingClientRect."); + return; + } + + view = View.create({ + render: function(buffer) { + buffer.push("Hello, world!"); + } + }); + + run(function() { view.appendTo('#qunit-fixture'); }); + + ok(Ember.ViewUtils.getViewBoundingClientRect(view) instanceof window.ClientRect); +});
true
Other
emberjs
ember.js
ee17c71909d030018881877018f86138d54f5c7b.json
Remove outdated model documentation.
packages/ember-routing/lib/system/route.js
@@ -1176,7 +1176,7 @@ var Route = EmberObject.extend(ActionHandler, { }); ``` - The model for the `post` route is `App.Post.find(params.post_id)`. + The model for the `post` route is `store.find('post', params.post_id)`. By default, if your route has a dynamic segment ending in `_id`: @@ -1219,7 +1219,7 @@ var Route = EmberObject.extend(ActionHandler, { ```js App.PostRoute = Ember.Route.extend({ model: function(params) { - return App.Post.find(params.post_id); + return this.store.find('post', params.post_id); } }); ``` @@ -1390,7 +1390,7 @@ var Route = EmberObject.extend(ActionHandler, { ```js App.PhotosRoute = Ember.Route.extend({ model: function() { - return App.Photo.find(); + return this.store.find('photo'); }, setupController: function (controller, model) {
false