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 | c959fc5cc68b83621371f713b4926ec09f7b5abd.json | Use module alias, don't break module bindings. | packages/ember-metal/lib/computed.js | @@ -1,7 +1,7 @@
import Ember from 'ember-metal/core';
import { set } from 'ember-metal/property_set';
import { inspect } from 'ember-metal/utils';
-import { meta } from 'ember-metal/meta';
+import { meta as metaFor } from 'ember-metal/meta';
import expandProperties from 'ember-metal/expand_properties';
import EmberError from 'ember-metal/error';
import {
@@ -22,7 +22,6 @@ import {
@submodule ember-metal
*/
-var metaFor = meta;
function UNDEFINED() { }
| false |
Other | emberjs | ember.js | 647b84dc3819f4b1e48f1fa8b668a529992f9c4a.json | Add 2.1.0-beta.1 to CHANGELOG.
[ci skip] | CHANGELOG.md | @@ -1,5 +1,20 @@
# Ember Changelog
+### 2.1.0-beta.1 (August 16, 2015)
+
+- [#10173](https://github.com/emberjs/ember.js/pull/10173) [BUGFIX] Ensure non-singleton injections are not cached incorrectly.
+- [#11966](https://github.com/emberjs/ember.js/pull/11966) [PERF] Refactor Meta.
+- [#12057](https://github.com/emberjs/ember.js/pull/12057) Allow `instanceInitializers` to set `customEvents`.
+- [#12059](https://github.com/emberjs/ember.js/pull/12059) [BUGFIX] Allow setting an entry in `Application#customEvents` to `null` to opt out of event listeners.
+- [#12034](https://github.com/emberjs/ember.js/pull/12034) [BUGFIX] Ensure `currentRouteName` and `currentPath` are set properly for loading and error routes.
+- [#12062](https://github.com/emberjs/ember.js/pull/12062) Remove the need for `this.__nextSuper`, and make debugging methods with `this._super` calls much easier.
+- [#12116](https://github.com/emberjs/ember.js/pull/12116) [FEATURE ember-debug-handlers] Enable by default.
+- [#12117](https://github.com/emberjs/ember.js/pull/12117) [FEATURE ember-registry-container-reform] Enable by default.
+- [#11440](https://github.com/emberjs/ember.js/pull/11440) [DEPRECATION] Deprecate using `instance.container.lookup` on first argument to `instanceInitializers`. Use `instance.lookup` instead.
+- [#11440](https://github.com/emberjs/ember.js/pull/11440) [DEPRECATION] Deprecate passing two arguments to an initializers `initialize` function.
+
+
+
### 2.0.0 (August 13, 2015)
- [#12036](https://github.com/emberjs/ember.js/pull/12036) Cleanup CP Set and Volatile | false |
Other | emberjs | ember.js | d34aaed42c7471744254eafdedeb5c8e3e077d2b.json | Add 1.13.0 - 1.13.8 + 2.0.0 to CHANGELOG.md.
[ci skip] | CHANGELOG.md | @@ -1,5 +1,233 @@
# Ember Changelog
+### 2.0.0 (August 13, 2015)
+
+- [#12036](https://github.com/emberjs/ember.js/pull/12036) Cleanup CP Set and Volatile
+- [#11993](https://github.com/emberjs/ember.js/pull/11993) [CLEANUP] Remove `Ember.TrackedArray` and `Ember.SubArray`.
+- [#11550](https://github.com/emberjs/ember.js/pull/11550) [BUGFIX] Ensure that specifying an observer in a child class only observes changes to the childs dependent keys.
+- [#10259](https://github.com/emberjs/ember.js/pull/10259) [BUGFIX] Make `Ember.computed.or` return the last falsey value (similar to `||`).
+- [#11957](https://github.com/emberjs/ember.js/pull/11957) [BUGFIX] Enable `Ember.DefaultResolver` to properly normalize hyphens (`-`).
+- [#11969](https://github.com/emberjs/ember.js/pull/11969) / [#11959](https://github.com/emberjs/ember.js/pull/11959) [DEPRECATE] Deprecate usage of `Ember.String.fmt`.
+- [#11990](https://github.com/emberjs/ember.js/pull/11990) [PERF] `@each` should remain a stable node for chains.
+- [#11964](https://github.com/emberjs/ember.js/pull/11964) [BUGFIX] Update htmlbars to v0.14.2.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.HTMLBars.makeViewHelper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.HTMLBars._registerHelper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.Handlebars.registerHelper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.Handlebars.makeBoundHelper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.Handlebars.makeViewHelper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.Handlebars.helper`.
+- [#11965](https://github.com/emberjs/ember.js/pull/11965) [CLEANUP] Remove `Ember.Handlebars.registerBoundHelper`.
+- [#12024](https://github.com/emberjs/ember.js/pull/12024) [CLEANUP] Remove `ComponentTemplateDeprecation` mixin.
+- [#12001](https://github.com/emberjs/ember.js/pull/12001) [CLEANUP] Remove {{with}} keyword's controller option.
+- [#12027](https://github.com/emberjs/ember.js/pull/12027) [CLEANUP] Remove deprecated `template` access in Ember.Component.
+- [#12019](https://github.com/emberjs/ember.js/pull/12019) [DOC] Add helpful assertion when using @each as a leaf in DK.
+- [#12020](https://github.com/emberjs/ember.js/pull/12020) [CLEANUP] Remove specifying `.render` method to views and components.
+- [#12027](https://github.com/emberjs/ember.js/pull/12027) [CLEANUP] Remove `positionalParams` specified to `Ember.Component` at extend time.
+- [#12027](https://github.com/emberjs/ember.js/pull/12027) [CLEANUP] Remove support for specifying `template` in a component.
+- [#12027](https://github.com/emberjs/ember.js/pull/12027) [CLEANUP] Remove deprecated `template` access in Ember.Component.
+- [#12028](https://github.com/emberjs/ember.js/pull/12028) [CLEANUP] Store actions in `actions` not `_actions`.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove `length` from `OrderedSet` and `Map`.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove `OrderedSet.prototype.length`.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove `Ember.libraries.each`.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove deprecated special `{{each}}` keys.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove Ember.Location.registerImplementation.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove `{{template}}` support.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove Ember.Route#setupControllers deprecation.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Remove Ember.Route#renderTemplates deprecation.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove Ember.Application#initialize.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove support for `Ember.Application.resolver`.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove support for resolver without `normalize`.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove IE6 & IE7 deprecation.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove returning string of attrs from helper support.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove support for returning string of attrs from helper.
+- [#11845](https://github.com/emberjs/ember.js/pull/11845) [CLEANUP] Remove support for `view` and `viewClass` with `{{outlet}}`.
+- [#11771](https://github.com/emberjs/ember.js/pull/11771) [CLEANUP] Remove deprecated `Controller#controllerFor`.
+- [#11750](https://github.com/emberjs/ember.js/pull/11750) [CLEANUP] Remove `metaPath`, `getMeta` and `setMeta`.
+- [#11854](https://github.com/emberjs/ember.js/pull/11854) [CLEANUP] Lots of deprecation removals.
+- [#11820](https://github.com/emberjs/ember.js/pull/11820) [CLEANUP] Remove sendEvent hook.
+- [#11815](https://github.com/emberjs/ember.js/pull/11815) [CLEANUP] Remove `{chainWatchers: null}` from `Meta.prototype`.
+- [#11819](https://github.com/emberjs/ember.js/pull/11819) [CLEANUP] Abstract chainWatchers into an object.
+- [#11824](https://github.com/emberjs/ember.js/pull/11824) Revert "[CLEANUP] Remove support for reversed args in `Ember.observer`.
+- [#11822](https://github.com/emberjs/ember.js/pull/11822) [BUGFIX] Deprecate `currentWhen` with `{{link-to}}`.
+- [#11838](https://github.com/emberjs/ember.js/pull/11838) [CLEANUP] Only register `Ember.ContainerView` when legacy view support enabled.
+- [#11852](https://github.com/emberjs/ember.js/pull/11852) [CLEANUP] Remove `Ember.RenderBuffer`.
+- [#11853](https://github.com/emberjs/ember.js/pull/11853) [CLEANUP] Remove deprecated `Registry` and `Container` behavior.
+- [#11850](https://github.com/emberjs/ember.js/pull/11850) [CLEANUP] Remove context switching `{{each}}` helper variant.
+- [#11878](https://github.com/emberjs/ember.js/pull/11878) [BUGFIX] Fix issue with QP routes named after `Object.prototype` properties.
+- [#11903](https://github.com/emberjs/ember.js/pull/11903) [BUGFIX] Upgrade RSVP + Backburner. Fixes a number of scenarios around testing rejected promise scenarios.
+- [#11914](https://github.com/emberjs/ember.js/pull/11914) [CLEANUP] Remove `Ember.oneWay`.
+- [#11895](https://github.com/emberjs/ember.js/pull/11895) [BUGFIX] Properly detect if the environment is Node.
+- [#11897](https://github.com/emberjs/ember.js/pull/11897) [CLEANUP] Remove globals lookup from templates.
+- [#11777](https://github.com/emberjs/ember.js/pull/11777) [CLEANUP] Remove context switching form of `{{#each model}}{{/each}}`, use `{{#each model as |item|}}{{/each}}` instead.
+- [#11484](https://github.com/emberjs/ember.js/pull/11484) [CLEANUP] Remove `Ember.ArrayController` support, use `ember-legacy-controllers` addon for support until 2.4.
+- [#11782](https://github.com/emberjs/ember.js/pull/11782) [CLEANUP] Remove support for reversed args in `Ember.observer`.
+- [#11722](https://github.com/emberjs/ember.js/pull/11722) [BUGFIX] Provide a better error when `InjectedProperty` is misused.
+- [#11691](https://github.com/emberjs/ember.js/pull/11691) [BUGFIX] `{{get}}` helper subscribes to values and can be updated.
+- [#11792](https://github.com/emberjs/ember.js/pull/11792) [CLEANUP] Remove `Application#then` support.
+- [#11737](https://github.com/emberjs/ember.js/pull/11737) [BUGFIX] Ensure `this` context inside former reduced computed macros is correct.
+- [#11790](https://github.com/emberjs/ember.js/pull/11790) [CLEANUP] Remove context switching `{{with foo}}` support.
+- [#11754](https://github.com/emberjs/ember.js/pull/11754) [CLEANUP] Remove `emptyView="Global.foo"` for Ember.View instances.
+- [#11746](https://github.com/emberjs/ember.js/pull/11746) [CLEANUP] Cleanup `Ember.get`:
+ - Remove support for globals: `Ember.get('App.foo')` and `Ember.get(null, 'App.foo')`.
+ - Remove support for `this`: `Ember.get(object, 'this.foo')`.
+ - Enforce strict usage with two arguments: `Ember.get(object, path)`.
+ - Assert object is a non-null object & path is a string.
+- [#11761](https://github.com/emberjs/ember.js/pull/11761) [CLEANUP] Cleanup `Ember.set`:
+ - Removes support for set with global paths.
+ - Removes support for set with 'this' paths.
+ - Removes support for set with null as first parameter.
+ - Path must be a string.
+ - Requires set to be passed in three or four arguments.
+- [#11797](https://github.com/emberjs/ember.js/pull/11797) [CLEANUP] Move support of `itemController`, `itemViewClass`, `itemView`, etc into `ember-legacy-views` addon.
+- [#11776](https://github.com/emberjs/ember.js/pull/11776) [CLEANUP] Remove deprecated support for `{{each foo as bar}}`.
+- [#11770](https://github.com/emberjs/ember.js/pull/11770) [CLEANUP] Remove deprecated `Controller#needs`, use `Ember.inject.controller()` instead.
+- [#11800](https://github.com/emberjs/ember.js/pull/11800) [CLEANUP] Move support of `{{view}}` helper into `ember-legacy-views` addon.
+- [#11804](https://github.com/emberjs/ember.js/pull/11804) [CLEANUP] Remove `EmberObject.createWithMixins`.
+- [#11786](https://github.com/emberjs/ember.js/pull/11786) [CLEANUP] Remove `{{with foo as bar}}` support.
+- [#11805](https://github.com/emberjs/ember.js/pull/11805) [CLEANUP] Remove deprecated `anyBy`, `everyProperty`, and `some`.
+- [#11788](https://github.com/emberjs/ember.js/pull/11788) [CLEANUP] Remove slash for a namespace in the `{{render}}` helper
+- [#11791](https://github.com/emberjs/ember.js/pull/11791) [CLEANUP] Remove support for actions in `events` key.
+- [#11794](https://github.com/emberjs/ember.js/pull/11794) [CLEANUP] Move `Ember.View` and `Ember.CoreView` into `ember-legacy-views` addon.
+- [#11796](https://github.com/emberjs/ember.js/pull/11796) [CLEANUP] Remove `Ember.beforeObserver`, `Ember.addBeforeObserver`, `Ember.removeBeforeObserver`, `Ember.beforeObserversFor`, `Ember._suspendBeforeObserver`, `Ember._suspendBeforeObservers`, and `Function.prototype.observesBefore`.
+- [#11806](https://github.com/emberjs/ember.js/pull/11806) [CLEANUP] Remove deprecated `Controller#transitionTo` and `Controller#replaceWith`.
+- [#11807](https://github.com/emberjs/ember.js/pull/11807) [CLEANUP] Remove deprecated `Ember.Handlebars.get`.
+- [#11808](https://github.com/emberjs/ember.js/pull/11808) [CLEANUP] Remove deprecated `Binding#oneWay`.
+- [#11809](https://github.com/emberjs/ember.js/pull/11809) [CLEANUP] Remove deprecated `Map#remove`.
+- [#11213](https://github.com/emberjs/ember.js/pull/11213) [CLEANUP] Remove chaining in Observable.set
+- [#11438](https://github.com/emberjs/ember.js/pull/11438) [CLEANUP] Remove CP semantics
+- [#11447](https://github.com/emberjs/ember.js/pull/11447) [CLEANUP] Remove `Ember.Set` (**not** `Ember.set`).
+- [#11443](https://github.com/emberjs/ember.js/pull/11443) [CLEANUP] Remove `Ember.LinkView`.
+- [#11439](https://github.com/emberjs/ember.js/pull/11439) [CLEANUP] Remove computed macros.
+- [#11648](https://github.com/emberjs/ember.js/pull/11648) [CLEANUP] Remove `Ember.computed.mapProperty`.
+- [#11460](https://github.com/emberjs/ember.js/pull/11460) [CLEANUP] Remove `Object.create` polyfill.
+- [#11448](https://github.com/emberjs/ember.js/pull/11448) [CLEANUP] Remove `Ember.DeferredMixin`.
+- [#11458](https://github.com/emberjs/ember.js/pull/11458) [CLEANUP] Remove `Ember.ArrayPolyfils`.
+- [#11449](https://github.com/emberjs/ember.js/pull/11449) [CLEANUP] Remove `Ember.RSVP.prototype.fail`.
+- [#11459](https://github.com/emberjs/ember.js/pull/11459) [CLEANUP] Remove `Ember.keys`.
+- [#11456](https://github.com/emberjs/ember.js/pull/11456) [CLEANUP] Remove `Ember.View.prototype.state & `Ember.View.prototype._states`.
+- [#11455](https://github.com/emberjs/ember.js/pull/11455) [CLEANUP] Remove `Ember.EnumerableUtils`.
+- [#11462](https://github.com/emberjs/ember.js/pull/11462) [CLEANUP] Remove `Object.defineProperty` polyfill.
+- [#11517](https://github.com/emberjs/ember.js/pull/11517) [DEPRECATION] Deprecate `this.resource` in `Router.map`.
+- [#11479](https://github.com/emberjs/ember.js/pull/11479) [CLEANUP] Remove `Ember.ObjectController`.
+- [#11513](https://github.com/emberjs/ember.js/pull/11513) [BUGFIX] Replace array computed macros with plain array versions.
+- [#11513](https://github.com/emberjs/ember.js/pull/11513) [CLEANUP] Remove `Ember.arrayComputed`, `Ember.reduceComputed`, `Ember.ArrayComputed`, and `Ember.ReduceComputed`.
+- [#11547](https://github.com/emberjs/ember.js/pull/11547) [CLEANUP] Remove work around for Safari's double finally on error bug.
+- [#11528](https://github.com/emberjs/ember.js/pull/11528) [BUGFIX] Add helpful assertion when using `Ember.computed.map` without a function callback.
+- [#11528](https://github.com/emberjs/ember.js/pull/11528) [BUGFIX] Add helpful assertion when using `Ember.computed.mapBy` without a string property name.
+- [#11587](https://github.com/emberjs/ember.js/pull/11587) [CLEANUP] Remove `{{bind-attr}}`.
+- [#11611](https://github.com/emberjs/ember.js/pull/11611) [CLEANUP] Remove `Ember.computed.filterProperty`.
+- [#11608](https://github.com/emberjs/ember.js/pull/11608) [CLEANUP] Remove `{{linkTo}}` helper (**not** `{{link-to}}`).
+- [#11706](https://github.com/emberjs/ember.js/pull/11706) [CLEANUP] Remove `Enumerable.rejectProperty`.
+- [#11708](https://github.com/emberjs/ember.js/pull/11708) [BUGFIX] Update `fillIn` test helper to trigger the `input` event.
+- [#11710](https://github.com/emberjs/ember.js/pull/11710) Add repository field to package.json
+- [#11700](https://github.com/emberjs/ember.js/pull/11700) [CLEANUP] Removes `Enumerable.findProperty`.
+- [#11707](https://github.com/emberjs/ember.js/pull/11707) [CLEANUP] Remove `Enumerable.everyBy`.
+- [#10701](https://github.com/emberjs/ember.js/pull/10701) Refactor `lazyGet`.
+- [#11262](https://github.com/emberjs/ember.js/pull/11262) Fix basic Fastboot usage.
+- [#11375](https://github.com/emberjs/ember.js/pull/11375) Transition feature flag infrastructure to modules.
+- [#11383](https://github.com/emberjs/ember.js/pull/11383) Update {{each-in}} to use ember-metal/should-display.
+- [#11396](https://github.com/emberjs/ember.js/pull/11396) Make Ember.Checkbox extend from Ember.Component.
+
+### 1.13.8 (August 13, 2015)
+
+- [#12056](https://github.com/emberjs/ember.js/pull/12056) [BUGFIX] Ensure initializers can augment `customEvents`.
+- [#12037](https://github.com/emberjs/ember.js/pull/12037) [BUGFIX] Fix error in some query params scenarios.
+- [#12058](https://github.com/emberjs/ember.js/pull/12058) [BUGFIX] Fix link-to with only qps linking to outdated route.
+- [#12061](https://github.com/emberjs/ember.js/pull/12061) [PERF] Improve performance of guidFor when reading an existing Ember.Object.
+- [#12067](https://github.com/emberjs/ember.js/pull/12067) [BUGFIX] Prevent `helper:@content-helper` lookup errors when using a paramless helper.
+- [#12071](https://github.com/emberjs/ember.js/pull/12071) [BUGFIX] Fix issue with accessing component attributes before initial render.
+- [#12073](https://github.com/emberjs/ember.js/pull/12073) [BUGFIX] Fix issue with events when invoking a component and specifying `classNames=`.
+
+
+### 1.13.7 (August 9, 2015)
+
+- [#12000](https://github.com/emberjs/ember.js/pull/12000) [DEPRECATION] Deprecate using `controller` for {{with}}
+- [#11946](https://github.com/emberjs/ember.js/pull/11946) [PERF] Speed up `AttrProxy` implementation.
+- [#11956](https://github.com/emberjs/ember.js/pull/11956) [BUGFIX] Ensure that `Ember.View.views` is present on deprecated `Ember.View`.
+- [#11960](https://github.com/emberjs/ember.js/pull/11960) [BUGFIX] Fix issue preventing proper rerendering when specifying bound properties to `{{link-to}}`.
+- [#12018](https://github.com/emberjs/ember.js/pull/12018) [DEPRECATION] Deprecate `{{#unbound}}{{/unbound}}`.
+- [#12018](https://github.com/emberjs/ember.js/pull/12018) [DEPRECATION] Deprecate `{{unbound}}` with multiple params.
+- [#11964](https://github.com/emberjs/ember.js/pull/11964) [BUGFIX] Update htmlbars to v0.13.35.
+- [#12017](https://github.com/emberjs/ember.js/pull/12017) [DEPRECATION] Deprecate specifying `render` function to `Ember.View` or `Ember.Component` at extend time.
+- [#11993](https://github.com/emberjs/ember.js/pull/11993) [DEPRECATION] Deprecate `Ember.TrackedArray` and `Ember.SubArray`.
+- [#11994](https://github.com/emberjs/ember.js/pull/11994) [DEPRECATION] Deprecate using `@each` as a leaf node in a dependent key. Refactor from `Ember.computed('foo.@each', function() {});` to `Ember.computed('foo.[]', function() { });`.
+- [#12026](https://github.com/emberjs/ember.js/pull/12026) [BUGFIX] Remove wasted dependent keys for `template` and `layout` properties of `Ember.View`/`Ember.Component`.
+
+
+### 1.13.6 (July 31, 2015)
+
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.Handlebars.makeViewHelper`.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.HTMLBars.makeViewHelper`.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.HTMLBars._registerHelper` (manual registration is no longer needed).
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.HTMLBars.makeBoundHelper` in favor of `Ember.Helper.helper`.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.Handlebars.makeBoundHelper` in favor of `Ember.Helper.helper`.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.Handlebars.registerBoundHelper` in favor of `Ember.Helper.helper`.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.Handlebars.helper` in favor of `Ember.Helper.helper` and automatic helper resolution.
+- [#11900](https://github.com/emberjs/ember.js/pull/11900) [DEPRECATION] Deprecate `Ember.Handlebars.registerHelper` in favor of `Ember.Helper.helper` and automatic helper resolution.
+- [#11832](https://github.com/emberjs/ember.js/pull/11832) [BUGFIX] Fix memory leaks with application creation and acceptance test helpers.
+- [#11826](https://github.com/emberjs/ember.js/pull/11826) [DEPRECATION] Deprecate Ember.ContainerView
+- [#11864](https://github.com/emberjs/ember.js/pull/11864) [BUGFIX] Ensure acceptance test helpers are removed during teardown.
+- [#11861](https://github.com/emberjs/ember.js/pull/11861) [BUGFIX] Update HTMLBars to allow duplicate {{each}} keys.
+- [#11889](https://github.com/emberjs/ember.js/pull/11889) [BUGFIX] Fix `attributeBindings` for `id` attribute.
+- [#11866](https://github.com/emberjs/ember.js/pull/11866) [BUGFIX] Fix DeprecatedView (and friends) reopen function to delegate to original.
+- [#11891](https://github.com/emberjs/ember.js/pull/11891) [DEPRECATION] Deprecate Ember.CollectionView
+- [#11910](https://github.com/emberjs/ember.js/pull/11910) [BUGFIX] Ensure `Ember.CollectionView.CONTAINER_MAP` is present on deprecated `CollectionView`.
+- [#11917](https://github.com/emberjs/ember.js/pull/11917) [BUGFIX] Ensure `"use strict";` is properly added for modules.
+- [#11934](https://github.com/emberjs/ember.js/pull/11934) [DEPRECATION] Deprecate specifying `positionalParams` at extend time in favor of using static factory properties.
+- [#11935](https://github.com/emberjs/ember.js/pull/11935) [BUGFIX] Avoid unnecessary change events during initial render.
+
+### 1.13.5 (July 19, 2015)
+
+- [#11767](https://github.com/emberjs/ember.js/pull/11767) [DEPRECATION] Deprecate Controller#needs
+- [#11468](https://github.com/emberjs/ember.js/pull/11468) [DEPRECATION] Deprecate `Ember.Freezable` and `frozenCopy`.
+- [#11762](https://github.com/emberjs/ember.js/pull/11762) / [#11744](https://github.com/emberjs/ember.js/pull/11744) [BUGFIX] Ensure deprecated `Ember.beforeObserver` is available in production.
+- [#11765](https://github.com/emberjs/ember.js/pull/11765) [DEPRECATION] Mark `Ember.oneWay` as deprecated
+- [#11774](https://github.com/emberjs/ember.js/pull/11774) [BUGFIX] Add deprecation warnings to deprecated Enumerable methods.
+- [#11778](https://github.com/emberjs/ember.js/pull/11778) [DEPRECATION] Deprecate reverse argument ordering in `Ember.observer`.
+- [#11787](https://github.com/emberjs/ember.js/pull/11787) [DEPRECATION] Deprecate slash for a namespace in the `{{render}}` helper.
+- [#11798](https://github.com/emberjs/ember.js/pull/11798) [DEPRECATION] Deprecate `Function#observesBefore`.
+- [#11812](https://github.com/emberjs/ember.js/pull/11812) [DEPRECATION] Add deprecation messages when using `Ember.get` / `Ember.set` in a certain ways.
+
+### 1.13.4 (July 13, 2015)
+
+- [#11651](https://github.com/emberjs/ember.js/pull/11651) [BUGFIX] Ensure child views of non-dirty components get the correct parentView when rerendered.
+- [#11662](https://github.com/emberjs/ember.js/pull/11662) [BUGFIX] Prevent ArrayController deprecation on generated controllers.
+- [#11655](https://github.com/emberjs/ember.js/pull/11655) [BUGFIX] Fix issue with blockless link-to with only query params.
+- [#11664](https://github.com/emberjs/ember.js/pull/11664) [BUGFIX] Ensure Route actions can be unit tested.
+- [#11667](https://github.com/emberjs/ember.js/pull/11667) [BUGFIX] Fix memory leak in rendering engine.
+
+### 1.13.3 (July 5, 2015)
+
+- [#11510](https://github.com/emberjs/ember.js/pull/11510) [DEPRECATION] Deprecate `Ember.Object.createWithMixins`.
+- [#11512](https://github.com/emberjs/ember.js/pull/11512) [DEPRECATION] Deprecate `Ember.oneWay` in favor of `Ember.computed.oneWay`.
+- [#11525](https://github.com/emberjs/ember.js/pull/11525) [BUGFIX] Add helpful error when using `{{each}}` with duplicate keys. This replaces a difficult to understand error deep in the HTMLBars internals, with an error that explains the duplicate key issue a bit better.
+- [#11511](https://github.com/emberjs/ember.js/pull/11511) [DEPRECATION] Deprecate `Ember.keys` in favor of `Object.keys`.
+- [#11511](https://github.com/emberjs/ember.js/pull/11511) [DEPRECATION] Deprecate `Ember.create` in favor of `Object.create`.
+- [#11543](https://github.com/emberjs/ember.js/pull/11543) / [#11594](https://github.com/emberjs/ember.js/pull/11594) / [#11603](https://github.com/emberjs/ember.js/pull/11603) - [BUGFIX] Fix extending or reopening `Ember.LinkView`.
+- [#11561](https://github.com/emberjs/ember.js/pull/11561) [BUGFIX] Fix issue with `{{link-to}}` not properly updating the link for certain routing state changes.
+- [#11572](https://github.com/emberjs/ember.js/pull/11572) [BUGFIX] Ensure local component state can shadow attributes provided during invocation.
+- [#11570](https://github.com/emberjs/ember.js/pull/11570) [BUGFIX] Prevent infinite loop when a yielded block param is changed.
+- [#11577](https://github.com/emberjs/ember.js/pull/11577) [BUGFIX] Ensure route backed views are properly destroyed.
+- [#11636](https://github.com/emberjs/ember.js/pull/11636) [BUGFIX] Fix sticky query params for nested and for dynamic routes.
+- [#11639](https://github.com/emberjs/ember.js/pull/11639) [BUGFIX] Fix testing of components containing `{{link-to}}`'s.
+- [#11650](https://github.com/emberjs/ember.js/pull/11650) [BUGFIX] Update HTMLBars to 0.13.32. Fixes a number of issues with the property first strategy used:
+ * for exceptions `input.form`, `input.list`, `button.type` always use `elem.setAttribute`
+ * for `form.action` always escape
+ * always assign handlers to props, even if the case appears strange
+
+### 1.13.2 (June 17, 2015)
+
+- [#11461](https://github.com/emberjs/ember.js/pull/11461) Remove `{{each}}` without `key=` warning. Deprecates `@guid` and `@item` in favor of the new default `@identity`.
+- [#11495](https://github.com/emberjs/ember.js/pull/11495) [PERFORMANCE] Remove debug statements from production builds.
+
+### 1.13.1 (June 16, 2015)
+
+- [#11445](https://github.com/emberjs/ember.js/pull/11445) [BUGFIX] Allow recomputation for `Ember.Helper` with arguments.
+- [#11317](https://github.com/emberjs/ember.js/pull/11317) [BUGFIX] Ensure handleURL called after setURL in visit helper.
+- [#11464](https://github.com/emberjs/ember.js/pull/11464) [DEPRECATION] Deprecate `Ember.immediateObserver`.
+- [#11476](https://github.com/emberjs/ember.js/pull/11476) [DEPRECATION] Deprecate `Ember.ArrayController`.
+- [#11478](https://github.com/emberjs/ember.js/pull/11478) [DEPRECATION] Deprecate `Ember.RenderBuffer`.
+
### 1.13.0 (June 12, 2015)
- [#11270](https://github.com/emberjs/ember.js/pull/11270) [BUGFIX] Ensure view registry is propagated to components. | false |
Other | emberjs | ember.js | 16eb4f803ca751c1f869f2c1e7e2c9b7ae79a7e6.json | Seperate instanceInitializer into its own section.
(cherry picked from commit f38acb3b339d3009acc7e9518e52f3b56d8f6724)
(cherry picked from commit 7fc8118eb89277411f72148b6735ea254b3fcd47) | packages/ember-application/lib/system/application.js | @@ -712,6 +712,69 @@ var Application = Namespace.extend(RegistryProxy, {
});
Application.reopenClass({
+ /**
+ Instance initializers run after all initializers have run. Because
+ instance initializers run after the app is fully set up. We have access
+ to the store, container, and other items. However, these initializers run
+ after code has loaded and are not allowed to defer readiness.
+
+ Instance initializer receives an object which has the following attributes:
+ `name`, `before`, `after`, `initialize`. The only required attribute is
+ `initialize`, all others are optional.
+
+ * `name` allows you to specify under which name the instanceInitializer is
+ registered. This must be a unique name, as trying to register two
+ instanceInitializer with the same name will result in an error.
+
+ ```javascript
+ Ember.Application.instanceInitializer({
+ name: 'namedinstanceInitializer',
+
+ initialize: function(application) {
+ Ember.debug('Running namedInitializer!');
+ }
+ });
+ ```
+
+ * `before` and `after` are used to ensure that this initializer is ran prior
+ or after the one identified by the value. This value can be a single string
+ or an array of strings, referencing the `name` of other initializers.
+
+ * See Ember.Application.initializer for discussion on the usage of before
+ and after.
+
+ Example instanceInitializer to preload data into the store.
+
+ ```javascript
+ Ember.Application.initializer({
+ name: 'preload-data',
+
+ initialize: function(application) {
+ var userConfig, userConfigEncoded, store;
+ // We have a HTML escaped JSON representation of the user's basic
+ // configuration generated server side and stored in the DOM of the main
+ // index.html file. This allows the app to have access to a set of data
+ // without making any additional remote calls. Good for basic data that is
+ // needed for immediate rendering of the page. Keep in mind, this data,
+ // like all local models and data can be manipulated by the user, so it
+ // should not be relied upon for security or authorization.
+ //
+ // Grab the encoded data from the meta tag
+ userConfigEncoded = Ember.$('head meta[name=app-user-config]').attr('content');
+ // Unescape the text, then parse the resulting JSON into a real object
+ userConfig = JSON.parse(unescape(userConfigEncoded));
+ // Lookup the store
+ store = application.lookup('service:store');
+ // Push the encoded JSON into the store
+ store.pushPayload(userConfig);
+ }
+ });
+ ```
+
+ @method instanceInitializer
+ @param instanceInitializer
+ @public
+ */
instanceInitializer: buildInitializerMethod('instanceInitializers', 'instance initializer')
});
@@ -757,6 +820,13 @@ Application.reopenClass({
instanceInitializers: new EmptyObject(),
/**
+ The goal of initializers should be to register dependencies and injections.
+ This phase runs once. Because these initializers may load code, they are
+ allowed to defer application readiness and advance it. If you need to access
+ the container or store you should use an InstanceInitializer that will be run
+ after all initializers and therefore after all code is loaded and the app is
+ ready.
+
Initializer receives an object which has the following attributes:
`name`, `before`, `after`, `initialize`. The only required attribute is
`initialize`, all others are optional.
@@ -865,7 +935,8 @@ Application.reopenClass({
@method initializer
@param initializer {Object}
@public
- */
+ */
+
initializer: buildInitializerMethod('initializers', 'initializer'),
/** | false |
Other | emberjs | ember.js | 0c1e11dc9229d3760803641e1c171e75a6122342.json | Collapse two Travis builds into one.
The build setup takes longer than actually running these. This updates
Travis config to run one less build, but the same actual tests. | .travis.yml | @@ -54,7 +54,6 @@ env:
matrix:
- TEST_SUITE=each-package-tests
- TEST_SUITE=built-tests EMBER_ENV=production DISABLE_JSCS=true DISABLE_JSHINT=true
- - TEST_SUITE=old-jquery
- - TEST_SUITE=extend-prototypes
+ - TEST_SUITE=old-jquery-and-extend-prototypes
- TEST_SUITE=node DISABLE_JSCS=true DISABLE_JSHINT=true
- TEST_SUITE=sauce | true |
Other | emberjs | ember.js | 0c1e11dc9229d3760803641e1c171e75a6122342.json | Collapse two Travis builds into one.
The build setup takes longer than actually running these. This updates
Travis config to run one less build, but the same actual tests. | bin/run-tests.js | @@ -141,12 +141,9 @@ switch (process.env.TEST_SUITE) {
console.log('suite: built-tests');
generateBuiltTests();
break;
- case 'old-jquery':
- console.log('suite: old-jquery');
+ case 'old-jquery-and-extend-prototypes':
+ console.log('suite: old-jquery-and-extend-prototypes');
generateOldJQueryTests();
- break;
- case 'extend-prototypes':
- console.log('suite: extend-prototypes');
generateExtendPrototypeTests();
break;
case 'all': | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/lib/env.js | @@ -1,5 +1,4 @@
import _Ember from 'ember-metal';
-import isEnabled from 'ember-metal/features';
import environment from 'ember-metal/environment';
import { hooks } from 'htmlbars-runtime'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/lib/helpers/each-in.js | @@ -3,7 +3,6 @@
@submodule ember-templates
*/
-import isEnabled from 'ember-metal/features';
import shouldDisplay from 'ember-views/streams/should_display';
/** | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/lib/keywords/get.js | @@ -4,7 +4,6 @@
*/
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import Stream from 'ember-metal/streams/stream';
import KeyStream from 'ember-metal/streams/key-stream';
import { isStream } from 'ember-metal/streams/utils'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/boolean_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/class_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/data_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import EmberObject from 'ember-runtime/system/object'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/href_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/property_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/sanitized_test.js | @@ -1,6 +1,5 @@
/* jshint scripturl:true */
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import compile from 'ember-template-compiler/system/compile';
import { SafeString } from 'ember-htmlbars/utils/string'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/style_test.js | @@ -1,7 +1,6 @@
/* globals EmberDev */
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import compile from 'ember-template-compiler/system/compile';
import { SafeString } from 'ember-htmlbars/utils/string'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/svg_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/attr_nodes/value_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/helpers/component_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import { set } from 'ember-metal/property_set';
import { get } from 'ember-metal/property_get';
import run from 'ember-metal/run_loop'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/helpers/each_in_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import Component from 'ember-views/views/component';
import compile from 'ember-template-compiler/system/compile';
import run from 'ember-metal/run_loop'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/helpers/get_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import run from 'ember-metal/run_loop';
import { Registry } from 'ember-runtime/system/container';
import compile from 'ember-template-compiler/system/compile'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/helpers/if_unless_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import run from 'ember-metal/run_loop';
import Namespace from 'ember-runtime/system/namespace';
import { Registry } from 'ember-runtime/system/container'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/integration/helper-lookup-test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import Registry from 'container/registry';
import compile from 'ember-template-compiler/system/compile';
import ComponentLookup from 'ember-views/component_lookup'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-htmlbars/tests/system/discover-known-helpers-test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import Registry from 'container/registry';
import Helper from 'ember-htmlbars/helper';
import { runDestroy } from 'ember-runtime/tests/utils'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing-htmlbars/lib/keywords/action.js | @@ -3,7 +3,6 @@
@submodule ember-templates
*/
-import isEnabled from 'ember-metal/features';
import { keyword } from 'htmlbars-runtime/hooks';
import closureAction from 'ember-routing-htmlbars/keywords/closure-action';
| true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing-htmlbars/lib/keywords/element-action.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core'; // assert
-import isEnabled from 'ember-metal/features';
import { uuid } from 'ember-metal/utils';
import run from 'ember-metal/run_loop';
import { readUnwrappedModel } from 'ember-views/streams/utils'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing-htmlbars/tests/helpers/closure_action_test.js | @@ -1,4 +1,3 @@
-import isEnabled from 'ember-metal/features';
import run from 'ember-metal/run_loop';
import compile from 'ember-template-compiler/system/compile';
import EmberComponent from 'ember-views/views/component'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing-htmlbars/tests/helpers/element_action_test.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core'; // A, FEATURES, assert
-import isEnabled from 'ember-metal/features';
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 | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing-views/lib/views/link.js | @@ -4,7 +4,6 @@
*/
import Ember from 'ember-metal/core'; // FEATURES, Logger, assert
-import isEnabled from 'ember-metal/features';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing/lib/system/dsl.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core'; // FEATURES, assert
-import isEnabled from 'ember-metal/features';
/**
@module ember | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing/lib/system/router.js | @@ -1,5 +1,4 @@
import Ember from 'ember-metal/core'; // FEATURES, Logger, assert
-import isEnabled from 'ember-metal/features';
import EmberError from 'ember-metal/error';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember-routing/tests/system/dsl_test.js | @@ -1,5 +1,4 @@
/* globals EmberDev */
-import isEnabled from 'ember-metal/features';
import EmberRouter from 'ember-routing/system/router';
import { HANDLERS } from 'ember-debug/handlers';
import {
@@ -128,7 +127,7 @@ QUnit.test('should add loading and error routes if _isRouterMapResult is true',
ok(router.router.recognizer.names['blork_error'], 'error route was added');
});
- QUnit.test('should not add loading and error routes if _isRouterMapResult is false', function() {
+QUnit.test('should not add loading and error routes if _isRouterMapResult is false', function() {
Router.map(function() {
this.route('blork');
}); | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember/tests/global-api-test.js | @@ -1,6 +1,5 @@
/*globals Ember */
import 'ember';
-import isEnabled from 'ember-metal/features';
QUnit.module('Global API Tests');
| true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember/tests/helpers/helper_registration_test.js | @@ -1,6 +1,5 @@
import 'ember';
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import helpers from 'ember-htmlbars/helpers';
import { compile } from 'ember-template-compiler';
import Helper, { helper } from 'ember-htmlbars/helper'; | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js | @@ -1,37 +1,12 @@
import 'ember';
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import { compile } from 'ember-template-compiler';
var Router, App, router, registry, container;
var set = Ember.set;
var aboutDefer, otherDefer;
-function basicEagerURLUpdateTest(setTagName) {
- expect(6);
-
- if (setTagName) {
- Ember.TEMPLATES.application = compile('{{outlet}}{{link-to \'Index\' \'index\' id=\'index-link\'}}{{link-to \'About\' \'about\' id=\'about-link\' tagName=\'span\'}}');
- }
-
- bootApplication();
- equal(updateCount, 0);
- Ember.run(Ember.$('#about-link'), 'click');
-
- // URL should be eagerly updated now
- equal(updateCount, 1);
- equal(router.get('location.path'), '/about');
-
- // Resolve the promise.
- Ember.run(aboutDefer, 'resolve');
- equal(router.get('location.path'), '/about');
-
- // Shouldn't have called update url again.
- equal(updateCount, 1);
- equal(router.get('location.path'), '/about');
-}
-
function bootApplication() {
router = container.lookup('router:main');
Ember.run(App, 'advanceReadiness'); | true |
Other | emberjs | ember.js | c021a5ae2a6a60245ce45d680c5b1e0d79efc097.json | Remove feature flagging import. | packages/ember/tests/routing/substates_test.js | @@ -1,6 +1,5 @@
import 'ember';
import Ember from 'ember-metal/core';
-import isEnabled from 'ember-metal/features';
import { compile } from 'ember-template-compiler';
import EmberView from 'ember-views/views/view';
| true |
Other | emberjs | ember.js | 0fbdf32544bb29db2a718ccee9245eb60604ebb1.json | Remove feature flags for ember-htmlbars-each-in. | FEATURES.md | @@ -90,33 +90,6 @@ for a detailed explanation.
Enables HTMLBars compiler to interpret `<x-foo></x-foo>` as a component
invocation (instead of a standard HTML5 style element).
-* `ember-htmlbars-each-in`
-
- Adds a helper for enumerating over the properties of an object in a
- Handlebars templates. For example, given this data:
-
- ```javascript
- {
- "Item 1": 1234,
- "Item 2": 3456
- }
- ```
-
- And this template:
-
- ```handlebars
- {{#each-in items as |key value|}}
- <p>{{key}}: {{value}}</p>
- {{/each-in}}
- ```
-
- The following output would be produced:
-
- ```html
- <p>Item 1: 1234</p>
- <p>Item 2: 3456</p>
- ```
-
* `ember-routing-transitioning-classes`
Disables eager URL updates during slow transitions in favor of new CSS | true |
Other | emberjs | ember.js | 0fbdf32544bb29db2a718ccee9245eb60604ebb1.json | Remove feature flags for ember-htmlbars-each-in. | features.json | @@ -2,7 +2,6 @@
"features": {
"features-stripped-test": null,
"ember-htmlbars-component-generation": null,
- "ember-htmlbars-each-in": true,
"ember-routing-transitioning-classes": true,
"ember-testing-checkbox-helpers": null,
"ember-metal-stream": null, | true |
Other | emberjs | ember.js | 0fbdf32544bb29db2a718ccee9245eb60604ebb1.json | Remove feature flags for ember-htmlbars-each-in. | packages/ember-htmlbars/lib/helpers/each-in.js | @@ -6,50 +6,48 @@
import isEnabled from 'ember-metal/features';
import shouldDisplay from 'ember-views/streams/should_display';
-if (isEnabled('ember-htmlbars-each-in')) {
- /**
- The `{{each-in}}` helper loops over properties on an object. It is unbound,
- in that new (or removed) properties added to the target object will not be
- rendered.
-
- For example, given a `user` object that looks like:
-
- ```javascript
- {
- "name": "Shelly Sails",
- "age": 42
- }
- ```
-
- This template would display all properties on the `user`
- object in a list:
-
- ```handlebars
- <ul>
- {{#each-in user as |key value|}}
- <li>{{key}}: {{value}}</li>
- {{/each-in}}
- </ul>
- ```
-
- Outputting their name and age.
-
- @method each-in
- @for Ember.Templates.helpers
- @public
- */
- var eachInHelper = function([ object ], hash, blocks) {
- var objKeys, prop, i;
- objKeys = object ? Object.keys(object) : [];
- if (shouldDisplay(objKeys)) {
- for (i = 0; i < objKeys.length; i++) {
- prop = objKeys[i];
- blocks.template.yieldItem(prop, [prop, object[prop]]);
- }
- } else if (blocks.inverse.yield) {
- blocks.inverse.yield();
+/**
+ The `{{each-in}}` helper loops over properties on an object. It is unbound,
+ in that new (or removed) properties added to the target object will not be
+ rendered.
+
+ For example, given a `user` object that looks like:
+
+ ```javascript
+ {
+ "name": "Shelly Sails",
+ "age": 42
+ }
+ ```
+
+ This template would display all properties on the `user`
+ object in a list:
+
+ ```handlebars
+ <ul>
+ {{#each-in user as |key value|}}
+ <li>{{key}}: {{value}}</li>
+ {{/each-in}}
+ </ul>
+ ```
+
+ Outputting their name and age.
+
+ @method each-in
+ @for Ember.Templates.helpers
+ @public
+*/
+var eachInHelper = function([ object ], hash, blocks) {
+ var objKeys, prop, i;
+ objKeys = object ? Object.keys(object) : [];
+ if (shouldDisplay(objKeys)) {
+ for (i = 0; i < objKeys.length; i++) {
+ prop = objKeys[i];
+ blocks.template.yieldItem(prop, [prop, object[prop]]);
}
- };
-}
+ } else if (blocks.inverse.yield) {
+ blocks.inverse.yield();
+ }
+};
export default eachInHelper; | true |
Other | emberjs | ember.js | 0fbdf32544bb29db2a718ccee9245eb60604ebb1.json | Remove feature flags for ember-htmlbars-each-in. | packages/ember-htmlbars/lib/main.js | @@ -141,9 +141,7 @@ registerHelper('with', withHelper);
registerHelper('loc', locHelper);
registerHelper('log', logHelper);
registerHelper('each', eachHelper);
-if (isEnabled('ember-htmlbars-each-in')) {
- registerHelper('each-in', eachInHelper);
-}
+registerHelper('each-in', eachInHelper);
registerHelper('-normalize-class', normalizeClassHelper);
registerHelper('concat', concatHelper);
registerHelper('-join-classes', joinClassesHelper); | true |
Other | emberjs | ember.js | 0fbdf32544bb29db2a718ccee9245eb60604ebb1.json | Remove feature flags for ember-htmlbars-each-in. | packages/ember-htmlbars/tests/helpers/each_in_test.js | @@ -23,118 +23,117 @@ function renderTemplate(_template, props) {
runAppend(component);
}
-if (isEnabled('ember-htmlbars-each-in')) {
- QUnit.test('it renders the template for each item in a hash', function(assert) {
- let categories = {
- 'Smartphones': 8203,
- 'JavaScript Frameworks': Infinity
- };
-
- renderTemplate(`
+QUnit.test('it renders the template for each item in a hash', function(assert) {
+ let categories = {
+ 'Smartphones': 8203,
+ 'JavaScript Frameworks': Infinity
+ };
+
+ renderTemplate(`
<ul class="categories">
{{#each-in categories as |category count|}}
<li>{{category}}: {{count}}</li>
{{/each-in}}
</ul>
`, { categories });
- assert.equal(component.$('li').length, 2, 'renders 2 lis');
- assert.equal(component.$('li').first().text(),
- 'Smartphones: 8203', 'renders first item correctly');
- assert.equal(component.$('li:eq(1)').text(),
- 'JavaScript Frameworks: Infinity', 'renders second item correctly');
+ assert.equal(component.$('li').length, 2, 'renders 2 lis');
+ assert.equal(component.$('li').first().text(),
+ 'Smartphones: 8203', 'renders first item correctly');
+ assert.equal(component.$('li:eq(1)').text(),
+ 'JavaScript Frameworks: Infinity', 'renders second item correctly');
- run(function() {
- component.rerender();
- });
+ run(function() {
+ component.rerender();
+ });
- assert.equal(component.$('li').length, 2, 'renders 2 lis after rerender');
- assert.equal(component.$('li').first().text(),
- 'Smartphones: 8203', 'renders first item correctly after rerender');
- assert.equal(component.$('li:eq(1)').text(),
- 'JavaScript Frameworks: Infinity', 'renders second item correctly after rerender');
+ assert.equal(component.$('li').length, 2, 'renders 2 lis after rerender');
+ assert.equal(component.$('li').first().text(),
+ 'Smartphones: 8203', 'renders first item correctly after rerender');
+ assert.equal(component.$('li:eq(1)').text(),
+ 'JavaScript Frameworks: Infinity', 'renders second item correctly after rerender');
- run(function() {
- component.set('categories', {
- 'Smartphones': 100
- });
+ run(function() {
+ component.set('categories', {
+ 'Smartphones': 100
});
+ });
- assert.equal(component.$('li').length, 1, 'removes unused item after data changes');
- assert.equal(component.$('li').first().text(),
- 'Smartphones: 100', 'correctly updates item after data changes');
+ assert.equal(component.$('li').length, 1, 'removes unused item after data changes');
+ assert.equal(component.$('li').first().text(),
+ 'Smartphones: 100', 'correctly updates item after data changes');
- run(function() {
- component.set('categories', {
- 'Programming Languages': 199303,
- 'Good Programming Languages': 123,
- 'Bad Programming Languages': 456
- });
+ run(function() {
+ component.set('categories', {
+ 'Programming Languages': 199303,
+ 'Good Programming Languages': 123,
+ 'Bad Programming Languages': 456
});
-
- assert.equal(component.$('li').length, 3, 'renders 3 lis after updating data');
- assert.equal(component.$('li').first().text(),
- 'Programming Languages: 199303', 'renders first item correctly after rerender');
- assert.equal(component.$('li:eq(1)').text(),
- 'Good Programming Languages: 123', 'renders second item correctly after rerender');
- assert.equal(component.$('li:eq(2)').text(),
- 'Bad Programming Languages: 456', 'renders third item correctly after rerender');
});
- QUnit.test('it only iterates over an object\'s own properties', function(assert) {
- let protoCategories = {
- 'Smartphones': 8203,
- 'JavaScript Frameworks': Infinity
- };
+ assert.equal(component.$('li').length, 3, 'renders 3 lis after updating data');
+ assert.equal(component.$('li').first().text(),
+ 'Programming Languages: 199303', 'renders first item correctly after rerender');
+ assert.equal(component.$('li:eq(1)').text(),
+ 'Good Programming Languages: 123', 'renders second item correctly after rerender');
+ assert.equal(component.$('li:eq(2)').text(),
+ 'Bad Programming Languages: 456', 'renders third item correctly after rerender');
+});
+
+QUnit.test('it only iterates over an object\'s own properties', function(assert) {
+ let protoCategories = {
+ 'Smartphones': 8203,
+ 'JavaScript Frameworks': Infinity
+ };
- let categories = Object.create(protoCategories);
- categories['Televisions'] = 183;
- categories['Alarm Clocks'] = 999;
+ let categories = Object.create(protoCategories);
+ categories['Televisions'] = 183;
+ categories['Alarm Clocks'] = 999;
- renderTemplate(`
+ renderTemplate(`
<ul class="categories">
{{#each-in categories as |category count|}}
<li>{{category}}: {{count}}</li>
{{/each-in}}
</ul>
`, { categories });
- assert.equal(component.$('li').length, 2, 'renders 2 lis');
- assert.equal(component.$('li').first().text(),
- 'Televisions: 183', 'renders first item correctly');
- assert.equal(component.$('li:eq(1)').text(),
- 'Alarm Clocks: 999', 'renders second item correctly');
+ assert.equal(component.$('li').length, 2, 'renders 2 lis');
+ assert.equal(component.$('li').first().text(),
+ 'Televisions: 183', 'renders first item correctly');
+ assert.equal(component.$('li:eq(1)').text(),
+ 'Alarm Clocks: 999', 'renders second item correctly');
- run(() => component.rerender());
+ run(() => component.rerender());
- assert.equal(component.$('li').length, 2, 'renders 2 lis after rerender');
- assert.equal(component.$('li').first().text(),
- 'Televisions: 183', 'renders first item correctly after rerender');
- assert.equal(component.$('li:eq(1)').text(),
- 'Alarm Clocks: 999', 'renders second item correctly after rerender');
- });
+ assert.equal(component.$('li').length, 2, 'renders 2 lis after rerender');
+ assert.equal(component.$('li').first().text(),
+ 'Televisions: 183', 'renders first item correctly after rerender');
+ assert.equal(component.$('li:eq(1)').text(),
+ 'Alarm Clocks: 999', 'renders second item correctly after rerender');
+});
- QUnit.test('it emits nothing if the passed argument is not an object', function(assert) {
- let categories = null;
+QUnit.test('it emits nothing if the passed argument is not an object', function(assert) {
+ let categories = null;
- renderTemplate(`
+ renderTemplate(`
<ul class="categories">
{{#each-in categories as |category count|}}
<li>{{category}}: {{count}}</li>
{{/each-in}}
</ul>
`, { categories });
- assert.equal(component.$('li').length, 0, 'nothing is rendered if the object is not passed');
+ assert.equal(component.$('li').length, 0, 'nothing is rendered if the object is not passed');
- run(() => component.rerender());
- assert.equal(component.$('li').length, 0, 'nothing is rendered if the object is not passed after rerender');
- });
+ run(() => component.rerender());
+ assert.equal(component.$('li').length, 0, 'nothing is rendered if the object is not passed after rerender');
+});
- QUnit.test('it supports rendering an inverse', function(assert) {
- let categories = null;
+QUnit.test('it supports rendering an inverse', function(assert) {
+ let categories = null;
- renderTemplate(`
+ renderTemplate(`
<ul class="categories">
{{#each-in categories as |category count|}}
<li>{{category}}: {{count}}</li>
@@ -144,27 +143,26 @@ if (isEnabled('ember-htmlbars-each-in')) {
</ul>
`, { categories });
- assert.equal(component.$('li').length, 1, 'one li is rendered');
- assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered');
+ assert.equal(component.$('li').length, 1, 'one li is rendered');
+ assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered');
- run(() => component.rerender());
- assert.equal(component.$('li').length, 1, 'one li is rendered');
- assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered');
+ run(() => component.rerender());
+ assert.equal(component.$('li').length, 1, 'one li is rendered');
+ assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered');
- run(() => {
- component.set('categories', {
- 'First Category': 123
- });
+ run(() => {
+ component.set('categories', {
+ 'First Category': 123
});
+ });
- assert.equal(component.$('li').length, 1, 'one li is rendered');
- assert.equal(component.$('li').text(), 'First Category: 123', 'the list is rendered after being set');
-
- run(() => {
- component.set('categories', null);
- });
+ assert.equal(component.$('li').length, 1, 'one li is rendered');
+ assert.equal(component.$('li').text(), 'First Category: 123', 'the list is rendered after being set');
- assert.equal(component.$('li').length, 1, 'one li is rendered');
- assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered when the value becomes falsey again');
+ run(() => {
+ component.set('categories', null);
});
-}
+
+ assert.equal(component.$('li').length, 1, 'one li is rendered');
+ assert.equal(component.$('li').text(), 'No categories.', 'the inverse is rendered when the value becomes falsey again');
+}); | true |
Other | emberjs | ember.js | 0604db16ea85496b294d31f4289fbf1687924e89.json | Add failing test for top-level {{partial}}
Currently a top-level partial that happens to have a single top-level
element confuses the heuristics in the component hook. | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -1004,11 +1004,25 @@ if (isEnabled('ember-htmlbars-component-generation')) {
});
let el = view.$(style.tagName);
- ok(el, 'precond - the view was rendered');
+ equal(el.length, 1, 'precond - the view was rendered');
+ equal(el.text(), 'In layout');
equal(el.attr('static-prop'), 'static text');
equal(el.attr('concat-prop'), 'dynamic text');
equal(el.attr('dynamic-prop'), undefined);
});
+
+ QUnit.skip(`partials templates should not be treated like a component layout for ${style.name}`, function() {
+ registry.register('template:_zomg', compile(`<p>In partial</p>`));
+ registry.register('template:components/non-block', compile(`<${style.tagName}>{{partial "zomg"}}</${style.tagName}>`));
+
+ view = appendViewFor('<non-block />');
+
+ let el = view.$(style.tagName).find('p');
+ equal(el.length, 1, 'precond - the partial was rendered');
+ equal(el.text(), 'In partial');
+ strictEqual(el.attr('id'), undefined, 'the partial should not get an id');
+ strictEqual(el.attr('class'), undefined, 'the partial should not get a class');
+ });
});
QUnit.skip('[FRAGMENT] non-block rendering a fragment', function() { | false |
Other | emberjs | ember.js | 92d4854ca35b010541730053eae5810c8fe0a0eb.json | Test all styles of top-level element in <GC>
Previously, we had hardcoded tests for two styles of top-level element
in a GlimmerComponent. For the layout of `<foo-bar>`, we had tests for
the top-level element being `<foo-bar>` itself and being a `<div>`.
A recent commit allowed the top-level element to also be any dasherized
element that was not registered as an Ember component (aka “web
components”). This commit modifies the tests to enumerate all three
styles and runs the same set of tests for each. | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -840,250 +840,175 @@ if (isEnabled('ember-htmlbars-component-generation')) {
}, `You cannot use triple curlies (e.g. style={{{ ... }}}) in the top-level element of the <non-block> template because it is a GlimmerComponent.`);
});
- QUnit.test('non-block without properties replaced with a div', function() {
- // The whitespace is added intentionally to verify that the heuristic is not "a single node" but
- // rather "a single non-whitespace, non-comment node"
- registry.register('template:components/non-block', compile(' <div>In layout</div> '));
+ let styles = [{
+ name: 'a div',
+ tagName: 'div'
+ }, {
+ name: 'an identity element',
+ tagName: 'non-block'
+ }, {
+ name: 'a web component',
+ tagName: 'not-an-ember-component'
+ }];
+
+ styles.forEach(style => {
+ QUnit.test(`non-block without attributes replaced with ${style.name}`, function() {
+ // The whitespace is added intentionally to verify that the heuristic is not "a single node" but
+ // rather "a single non-whitespace, non-comment node"
+ registry.register('template:components/non-block', compile(` <${style.tagName}>In layout</${style.tagName}> `));
- view = appendViewFor('<non-block />');
-
- equal(view.$().text(), ' In layout ');
- ok(view.$().html().match(/^ <div id="[^"]*" class="ember-view">In layout<\/div> $/), 'The root element has gotten the default class and ids');
- ok(view.$('div.ember-view[id]').length === 1, 'The div became an Ember view');
-
- run(view, 'rerender');
+ view = appendViewFor('<non-block />');
- equal(view.$().text(), ' In layout ');
- ok(view.$().html().match(/^ <div id="[^"]*" class="ember-view">In layout<\/div> $/), 'The root element has gotten the default class and ids');
- ok(view.$('div.ember-view[id]').length === 1, 'The non-block tag name was used');
- });
+ let node = view.element.firstElementChild;
+ equalsElement(node, style.tagName, { class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
- QUnit.test('non-block without properties replaced with identity element', function() {
- registry.register('template:components/non-block', compile('<non-block such="{{attrs.stability}}">In layout</non-block>'));
+ run(view, 'rerender');
- view = appendViewFor('<non-block stability={{view.stability}} />', {
- stability: 'stability'
+ strictEqual(node, view.element.firstElementChild, 'The inner element has not changed');
+ equalsElement(node, style.tagName, { class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
});
- let node = view.$()[0];
- equal(view.$().text(), 'In layout');
- equalsElement(node.firstElementChild, 'non-block', { such: 'stability', class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
- ok(view.$('non-block.ember-view[id][such=stability]').length === 1, 'The non-block tag name was used');
+ QUnit.test(`non-block with attributes replaced with ${style.name}`, function() {
+ registry.register('template:components/non-block', compile(` <${style.tagName} such="{{attrs.stability}}">In layout</${style.tagName}> `));
- run(() => view.set('stability', 'changed!!!'));
+ view = appendViewFor('<non-block stability={{view.stability}} />', {
+ stability: 'stability'
+ });
- strictEqual(view.$()[0], node, 'the DOM node has remained stable');
- equal(view.$().text(), 'In layout');
- equalsElement(node.firstElementChild, 'non-block', { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
- });
+ let node = view.element.firstElementChild;
+ equalsElement(node, style.tagName, { such: 'stability', class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
- QUnit.test('non-block without properties replaced with identity element (regression if identity element has a single child element)', function() {
- registry.register('template:components/non-block', compile('<non-block such="{{attrs.stability}}"><p>In layout</p></non-block>'));
+ run(() => view.set('stability', 'changed!!!'));
- view = appendViewFor('<non-block stability={{view.stability}} />', {
- stability: 'stability'
+ strictEqual(node, view.element.firstElementChild, 'The inner element has not changed');
+ equalsElement(node, style.tagName, { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
});
- let node = view.$()[0];
- equal(view.$().text(), 'In layout');
- equalsElement(node.firstElementChild, 'non-block', { such: 'stability', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
- ok(view.$('non-block.ember-view[id][such=stability]').length === 1, 'The non-block tag name was used');
+ QUnit.test(`non-block replaced with ${style.name} (regression with single element in the root element)`, function() {
+ registry.register('template:components/non-block', compile(` <${style.tagName} such="{{attrs.stability}}"><p>In layout</p></${style.tagName}> `));
- run(() => view.set('stability', 'changed!!!'));
+ view = appendViewFor('<non-block stability={{view.stability}} />', {
+ stability: 'stability'
+ });
- strictEqual(view.$()[0], node, 'the DOM node has remained stable');
- equal(view.$().text(), 'In layout');
- equalsElement(node.firstElementChild, 'non-block', { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
- });
+ let node = view.element.firstElementChild;
+ equalsElement(node, style.tagName, { such: 'stability', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
- QUnit.test('non-block with class replaced with a div merges classes', function() {
- registry.register('template:components/non-block', compile('<div class="inner-class" />'));
+ run(() => view.set('stability', 'changed!!!'));
- view = appendViewFor('<non-block class="{{view.outer}}" />', {
- outer: 'outer'
+ strictEqual(node, view.element.firstElementChild, 'The inner element has not changed');
+ equalsElement(node, style.tagName, { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
});
- equal(view.$('div').attr('class'), 'inner-class outer ember-view', 'the classes are merged');
+ QUnit.test(`non-block with class replaced with ${style.name} merges classes`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName} class="inner-class" />`));
- run(() => view.set('outer', 'new-outer'));
+ view = appendViewFor('<non-block class="{{view.outer}}" />', {
+ outer: 'outer'
+ });
- equal(view.$('div').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
- });
+ equal(view.$(style.tagName).attr('class'), 'inner-class outer ember-view', 'the classes are merged');
- QUnit.test('non-block with class replaced with identity element merges classes', function() {
- registry.register('template:components/non-block', compile('<non-block class="inner-class" />'));
+ run(() => view.set('outer', 'new-outer'));
- view = appendViewFor('<non-block class="{{view.outer}}" />', {
- outer: 'outer'
+ equal(view.$(style.tagName).attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
});
- equal(view.$('non-block').attr('class'), 'inner-class outer ember-view', 'the classes are merged');
-
- run(() => view.set('outer', 'new-outer'));
-
- equal(view.$('non-block').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
- });
-
- QUnit.test('non-block with outer attributes replaced with a div shadows inner attributes', function() {
- registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
-
- view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
-
- equal(view.$('div').attr('data-static'), 'outer', 'the outer attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer attribute wins');
-
- let component = view.childViews[0]; // HAX
-
- run(() => component.set('internal', 'changed'));
-
- equal(view.$('div').attr('data-static'), 'outer', 'the outer attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer attribute wins');
- });
-
- QUnit.test('non-block with outer attributes replaced with identity element shadows inner attributes', function() {
- registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
-
- view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
-
- equal(view.$('non-block').attr('data-static'), 'outer', 'the outer attribute wins');
- equal(view.$('non-block').attr('data-dynamic'), 'outer', 'the outer attribute wins');
-
- let component = view.childViews[0]; // HAX
-
- run(() => component.set('internal', 'changed'));
-
- equal(view.$('non-block').attr('data-static'), 'outer', 'the outer attribute wins');
- equal(view.$('non-block').attr('data-dynamic'), 'outer', 'the outer attribute wins');
- });
+ QUnit.test(`non-block with outer attributes replaced with ${style.name} shadows inner attributes`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName} data-static="static" data-dynamic="{{internal}}" />`));
- QUnit.skip('non-block recursive invocations with outer attributes replaced with a div shadows inner attributes', function() {
- registry.register('template:components/non-block-wrapper', compile('<non-block />'));
- registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
+ view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
- view = appendViewFor('<non-block-wrapper data-static="outer" data-dynamic="outer" />');
+ equal(view.$(style.tagName).attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$(style.tagName).attr('data-dynamic'), 'outer', 'the outer attribute wins');
- equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+ let component = view.childViews[0]; // HAX
- let component = view.childViews[0].childViews[0]; // HAX
+ run(() => component.set('internal', 'changed'));
- run(() => component.set('internal', 'changed'));
-
- equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
- });
-
- QUnit.skip('non-block recursive invocations with outer attributes replaced with identity element shadows inner attributes', function() {
- registry.register('template:components/non-block-wrapper', compile('<non-block />'));
- registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
-
- view = appendViewFor('<non-block-wrapper data-static="outer" data-dynamic="outer" />');
-
- equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
-
- let component = view.childViews[0].childViews[0]; // HAX
-
- run(() => component.set('internal', 'changed'));
-
- equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
- equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
- });
-
- QUnit.test('non-block replaced with a div should have correct scope', function() {
- registry.register('template:components/non-block', compile('<div>{{internal}}</div>'));
-
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- this.set('internal', 'stuff');
- }
- }));
-
- view = appendViewFor('<non-block />');
-
- equal(view.$().text(), 'stuff');
- });
+ equal(view.$(style.tagName).attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$(style.tagName).attr('data-dynamic'), 'outer', 'the outer attribute wins');
+ });
- QUnit.test('non-block replaced with identity element should have correct scope', function() {
- registry.register('template:components/non-block', compile('<non-block>{{internal}}</non-block>'));
+ // TODO: When un-skipping, fix this so it handles all styles
+ QUnit.skip('non-block recursive invocations with outer attributes replaced with a div shadows inner attributes', function() {
+ registry.register('template:components/non-block-wrapper', compile('<non-block />'));
+ registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- this.set('internal', 'stuff');
- }
- }));
+ view = appendViewFor('<non-block-wrapper data-static="outer" data-dynamic="outer" />');
- view = appendViewFor('<non-block />');
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
- equal(view.$().text(), 'stuff');
- });
+ let component = view.childViews[0].childViews[0]; // HAX
- QUnit.test('non-block replaced with a div should have correct `element`', function() {
- registry.register('template:components/non-block', compile('<div />'));
+ run(() => component.set('internal', 'changed'));
- let component;
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+ });
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- component = this;
- }
- }));
+ QUnit.test(`non-block replaced with ${style.name} should have correct scope`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName}>{{internal}}</${style.tagName}>`));
- view = appendViewFor('<non-block />');
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
- equal(component.element, view.$('div')[0]);
- });
+ view = appendViewFor('<non-block />');
- QUnit.test('non-block replaced with identity element should have correct `element`', function() {
- registry.register('template:components/non-block', compile('<non-block />'));
+ equal(view.$().text(), 'stuff');
+ });
- let component;
+ QUnit.test(`non-block replaced with ${style.name} should have correct 'element'`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName} />`));
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- component = this;
- }
- }));
+ let component;
- view = appendViewFor('<non-block />');
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ component = this;
+ }
+ }));
- equal(component.element, view.$('non-block')[0]);
- });
+ view = appendViewFor('<non-block />');
- QUnit.test('non-block replaced with a div should have inner attributes', function() {
- registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
+ equal(component.element, view.$(style.tagName)[0]);
+ });
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- this.set('internal', 'stuff');
- }
- }));
+ QUnit.test(`non-block replaced with ${style.name} should have inner attributes`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName} data-static="static" data-dynamic="{{internal}}" />`));
- view = appendViewFor('<non-block />');
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
- equal(view.$('div').attr('data-static'), 'static');
- equal(view.$('div').attr('data-dynamic'), 'stuff');
- });
+ view = appendViewFor('<non-block />');
- QUnit.test('non-block replaced with identity element should have inner attributes', function() {
- registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
+ equal(view.$(style.tagName).attr('data-static'), 'static');
+ equal(view.$(style.tagName).attr('data-dynamic'), 'stuff');
+ });
- registry.register('component:non-block', GlimmerComponent.extend({
- init() {
- this._super(...arguments);
- this.set('internal', 'stuff');
- }
- }));
+ QUnit.test(`only text attributes are reflected on the underlying DOM element (${style.name})`, function() {
+ registry.register('template:components/non-block', compile(`<${style.tagName}>In layout</${style.tagName}>`));
- view = appendViewFor('<non-block />');
+ view = appendViewFor('<non-block static-prop="static text" concat-prop="{{view.dynamic}} text" dynamic-prop={{view.dynamic}} />', {
+ dynamic: 'dynamic'
+ });
- equal(view.$('non-block').attr('data-static'), 'static');
- equal(view.$('non-block').attr('data-dynamic'), 'stuff');
+ let el = view.$(style.tagName);
+ ok(el, 'precond - the view was rendered');
+ equal(el.attr('static-prop'), 'static text');
+ equal(el.attr('concat-prop'), 'dynamic text');
+ equal(el.attr('dynamic-prop'), undefined);
+ });
});
QUnit.skip('[FRAGMENT] non-block rendering a fragment', function() {
@@ -1112,22 +1037,6 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('with-block.ember-view').text(), 'In layout - In template', 'Both the layout and template are rendered');
});
- QUnit.test('non-block with properties on attrs', function() {
- registry.register('template:components/non-block', compile('<non-block>In layout</non-block>'));
-
- view = appendViewFor('<non-block static-prop="static text" concat-prop="{{view.dynamic}} text" dynamic-prop={{view.dynamic}} />', {
- dynamic: 'dynamic'
- });
-
- let el = view.$('non-block.ember-view');
- ok(el, 'precond - the view was rendered');
- equal(el.attr('static-prop'), 'static text');
- equal(el.attr('concat-prop'), 'dynamic text');
- equal(el.attr('dynamic-prop'), undefined);
-
- //equal(jQuery('#qunit-fixture').text(), 'In layout - someProp: something here');
- });
-
QUnit.test('attributes are not installed on the top level', function() {
let component;
| false |
Other | emberjs | ember.js | 29af9007c04887e0931e96926340a67dd86d1c69.json | Update HTMLBars to 0.14.3. | package.json | @@ -32,7 +32,7 @@
"finalhandler": "^0.4.0",
"github": "^0.2.3",
"glob": "~4.3.2",
- "htmlbars": "0.14.2",
+ "htmlbars": "0.14.3",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5", | false |
Other | emberjs | ember.js | 64247979b8d112de7a89c259ca3e6edc9061abca.json | Optimize the AST transform for top-level elements
Don’t bother to convert top-level elements into dynamic calls if they
aren’t the top-level element *of a template*.
Consider a template like this:
```
{{#each posts as |post|}}
<div>hello</div>
{{/each}}
```
The previous version of the transform would convert the nested template
(the <div>) into a dynamic call, because the AST transformation didn’t
differentiate between top-level templates and nested templates. It
didn’t have any other effects (the dynamic call is required to restore
the semantics of the original static form) but it unnecessarily bloats
templates and makes execution slower. | packages/ember-template-compiler/lib/plugins/transform-top-level-components.js | @@ -13,7 +13,7 @@ function TransformTopLevelComponents() {
TransformTopLevelComponents.prototype.transform = function TransformTopLevelComponents_transform(ast) {
let b = this.syntax.builders;
- hasSingleComponentNode(ast.body, component => {
+ hasSingleComponentNode(ast, component => {
if (component.type === 'ComponentNode') {
component.tag = `@${component.tag}`;
component.isStatic = true;
@@ -35,7 +35,10 @@ TransformTopLevelComponents.prototype.transform = function TransformTopLevelComp
return ast;
};
-function hasSingleComponentNode(body, componentCallback, elementCallback) {
+function hasSingleComponentNode(program, componentCallback, elementCallback) {
+ let { loc, body } = program;
+ if (!loc || loc.start.line !== 1 || loc.start.column !== 0) { return; }
+
let lastComponentNode;
let lastIndex;
let nodeCount = 0; | false |
Other | emberjs | ember.js | 87e021a83559001dec692e6872a69ce2752f8f59.json | Make regular elements like identity elements
In Ember 1.x components, the top-level element was configured in
JavaScript using APIs like `classNames`, `attributeBindings`, `tagName`
etc.
Glimmer components move that configuration into a top-level element in
the template. However, the template compiler does not know how the
template will actually be used, so it makes all top-level elements
dynamic, and leaves it up to the runtime to figure out what to do.
If the template is being invoked for a curly component, the runtime
restores the original semantics, treating it just like a regular
element.
If the template is being invoked for an angle-bracket component, the
top-level element is treated as the component’s element.
This commit makes top-level `<div>`s work correctly in Glimmer
components (they become the component’s element), and work correctly
in curly components (they behave as before).
Both modifiers (`<div {{action “foo”}}>`) and triple-curly attributes
are not supported in top-level elements of Glimmer components. As a
result, if the AST transformation sees either of those two features,
it assumes the template is for a curly component, and does not make the
root element dynamic.
At the moment, it would be impossible to support either of those two
features, since the component AST node in HTMLBars do not support them.
Ultimately, we may want to support triple-curly attributes, but probably
not modifiers.
Note that this commit requires an update to HTMLBars master. | packages/ember-htmlbars/lib/hooks/component.js | @@ -1,5 +1,5 @@
import ComponentNodeManager from 'ember-htmlbars/node-managers/component-node-manager';
-import buildComponentTemplate from 'ember-views/system/build-component-template';
+import buildComponentTemplate, { buildHTMLTemplate } from 'ember-views/system/build-component-template';
export default function componentHook(renderNode, env, scope, _tagName, params, attrs, templates, visitor) {
var state = renderNode.state;
@@ -27,10 +27,33 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
isDasherized = true;
}
- var parentView = env.view;
+ let parentView = env.view;
- if (isTopLevel && tagName === env.view.tagName || !isDasherized) {
- let component = env.view;
+ // | Top-level | Invocation: <foo-bar> | Invocation: {{foo-bar}} |
+ // ----------------------------------------------------------------------
+ // | <div> | <div> is component el | no special semantics (a) |
+ // | <foo-bar> | <foo-bar> is identity el | EWTF |
+ // | <bar-baz> | recursive invocation | no special semantics |
+ // | {{anything}} | EWTF | no special semantics |
+ //
+ // (a) needs to be implemented specially, because the usual semantics of
+ // <div> are defined by the compiled template, and we need to emulate
+ // those semantics.
+
+ let component = env.view;
+ let isInvokedWithAngles = component && component._isAngleBracket;
+ let isInvokedWithCurlies = component && !component._isAngleBracket;
+
+ // <div> at the top level of a <foo-bar> invocation
+ let isComponentHTMLElement = isAngleBracket && !isDasherized && isInvokedWithAngles;
+
+ // <foo-bar> at the top level of a <foo-bar> invocation
+ let isComponentIdentityElement = isAngleBracket && isTopLevel && tagName === env.view.tagName;
+
+ // <div> at the top level of a {{foo-bar}} invocation
+ let isNormalHTMLElement = isAngleBracket && !isDasherized && isInvokedWithCurlies;
+
+ if (isComponentIdentityElement || isComponentHTMLElement) {
let templateOptions = {
component,
tagName,
@@ -44,7 +67,12 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
let { block } = buildComponentTemplate(templateOptions, attrs, contentOptions);
block(env, [], undefined, renderNode, scope, visitor);
+ } else if (isNormalHTMLElement) {
+ let block = buildHTMLTemplate(tagName, attrs, { templates, scope });
+ block(env, [], undefined, renderNode, scope, visitor);
} else {
+ // "No special semantics" aka we are invoking a component
+
var manager = ComponentNodeManager.create(renderNode, env, {
tagName,
params, | true |
Other | emberjs | ember.js | 87e021a83559001dec692e6872a69ce2752f8f59.json | Make regular elements like identity elements
In Ember 1.x components, the top-level element was configured in
JavaScript using APIs like `classNames`, `attributeBindings`, `tagName`
etc.
Glimmer components move that configuration into a top-level element in
the template. However, the template compiler does not know how the
template will actually be used, so it makes all top-level elements
dynamic, and leaves it up to the runtime to figure out what to do.
If the template is being invoked for a curly component, the runtime
restores the original semantics, treating it just like a regular
element.
If the template is being invoked for an angle-bracket component, the
top-level element is treated as the component’s element.
This commit makes top-level `<div>`s work correctly in Glimmer
components (they become the component’s element), and work correctly
in curly components (they behave as before).
Both modifiers (`<div {{action “foo”}}>`) and triple-curly attributes
are not supported in top-level elements of Glimmer components. As a
result, if the AST transformation sees either of those two features,
it assumes the template is for a curly component, and does not make the
root element dynamic.
At the moment, it would be impossible to support either of those two
features, since the component AST node in HTMLBars do not support them.
Ultimately, we may want to support triple-curly attributes, but probably
not modifiers.
Note that this commit requires an update to HTMLBars master. | packages/ember-template-compiler/lib/plugins/transform-top-level-components.js | @@ -16,11 +16,20 @@ TransformTopLevelComponents.prototype.transform = function TransformTopLevelComp
hasSingleComponentNode(ast.body, component => {
if (component.type === 'ComponentNode') {
component.tag = `@${component.tag}`;
+ component.isStatic = true;
}
}, element => {
- // TODO: Properly copy loc from children
- let program = b.program(element.children);
- return b.component(`@<${element.tag}>`, element.attributes, program, element.loc);
+ let hasTripleCurlies = element.attributes.some(attr => attr.value.escaped === false);
+
+ if (element.modifiers.length || hasTripleCurlies) {
+ return element;
+ } else {
+ // TODO: Properly copy loc from children
+ let program = b.program(element.children);
+ let component = b.component(`@<${element.tag}>`, element.attributes, program, element.loc);
+ component.isStatic = true;
+ return component;
+ }
});
return ast; | true |
Other | emberjs | ember.js | 87e021a83559001dec692e6872a69ce2752f8f59.json | Make regular elements like identity elements
In Ember 1.x components, the top-level element was configured in
JavaScript using APIs like `classNames`, `attributeBindings`, `tagName`
etc.
Glimmer components move that configuration into a top-level element in
the template. However, the template compiler does not know how the
template will actually be used, so it makes all top-level elements
dynamic, and leaves it up to the runtime to figure out what to do.
If the template is being invoked for a curly component, the runtime
restores the original semantics, treating it just like a regular
element.
If the template is being invoked for an angle-bracket component, the
top-level element is treated as the component’s element.
This commit makes top-level `<div>`s work correctly in Glimmer
components (they become the component’s element), and work correctly
in curly components (they behave as before).
Both modifiers (`<div {{action “foo”}}>`) and triple-curly attributes
are not supported in top-level elements of Glimmer components. As a
result, if the AST transformation sees either of those two features,
it assumes the template is for a curly component, and does not make the
root element dynamic.
At the moment, it would be impossible to support either of those two
features, since the component AST node in HTMLBars do not support them.
Ultimately, we may want to support triple-curly attributes, but probably
not modifiers.
Note that this commit requires an update to HTMLBars master. | packages/ember-views/lib/system/build-component-template.js | @@ -47,6 +47,30 @@ export default function buildComponentTemplate({ component, tagName, layout, isA
return { createdElement: !!tagName, block: blockToRender };
}
+export function buildHTMLTemplate(tagName, _attrs, content) {
+ let attrs = {};
+
+ for (let prop in _attrs) {
+ let val = _attrs[prop];
+
+ if (typeof val === 'string') {
+ attrs[prop] = val;
+ } else {
+ attrs[prop] = ['value', val];
+ }
+ }
+
+ let childTemplate = content.templates.default;
+ let elementTemplate = internal.manualElement(tagName, attrs, childTemplate.isEmpty);
+
+ if (childTemplate.isEmpty) {
+ return blockFor(elementTemplate, { scope: content.scope });
+ } else {
+ let blockToRender = blockFor(content.templates.default, content);
+ return blockFor(elementTemplate, { yieldTo: blockToRender, scope: content.scope });
+ }
+}
+
function mergeAttrs(innerAttrs, outerAttrs) {
let result = assign({}, innerAttrs, outerAttrs);
| true |
Other | emberjs | ember.js | fc20f0a5205359ca1b01a8403002724dc79af046.json | FIx typo in docs for `mut` helper | packages/ember-htmlbars/lib/keywords/mut.js | @@ -16,7 +16,7 @@ export let MUTABLE_REFERENCE = symbol('MUTABLE_REFERENCE');
/**
The `mut` helper lets you __clearly specify__ that a child `Component` can update the
- (mutable) value passed to it, which will __change the value of the parent compnent__.
+ (mutable) value passed to it, which will __change the value of the parent component__.
This is very helpful for passing mutable values to a `Component` of any size, but
critical to understanding the logic of a large/complex `Component`. | false |
Other | emberjs | ember.js | ca436a2b1d4d488a6aeadd9ba7e6ab170e3a5e49.json | WIP: make regular elements like identity elements | packages/ember-htmlbars/lib/hooks/component.js | @@ -12,7 +12,8 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
let tagName = _tagName;
let isAngleBracket = false;
- let isTopLevel;
+ let isTopLevel = false;
+ let isDasherized = false;
let angles = tagName.match(/^(@?)<(.*)>$/);
@@ -22,12 +23,17 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
isTopLevel = !!angles[1];
}
+ if (tagName.indexOf('-') !== -1) {
+ isDasherized = true;
+ }
+
var parentView = env.view;
- if (isTopLevel && tagName === env.view.tagName) {
+ if (isTopLevel && tagName === env.view.tagName || !isDasherized) {
let component = env.view;
let templateOptions = {
component,
+ tagName,
isAngleBracket: true,
isComponentElement: true,
outerAttrs: scope.attrs, | true |
Other | emberjs | ember.js | ca436a2b1d4d488a6aeadd9ba7e6ab170e3a5e49.json | WIP: make regular elements like identity elements | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -1043,7 +1043,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$().html(), '<div>This is a</div><div>fragment</div>', 'Just the fragment was used');
});
- QUnit.skip('non-block without properties replaced with a div', function() {
+ QUnit.test('non-block without properties replaced with a div', function() {
// The whitespace is added intentionally to verify that the heuristic is not "a single node" but
// rather "a single non-whitespace, non-comment node"
registry.register('template:components/non-block', compile(' <div>In layout</div> '));
@@ -1099,7 +1099,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equalsElement(node.firstElementChild, 'non-block', { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
});
- QUnit.skip('non-block with class replaced with a div merges classes', function() {
+ QUnit.test('non-block with class replaced with a div merges classes', function() {
registry.register('template:components/non-block', compile('<div class="inner-class" />'));
view = appendViewFor('<non-block class="{{view.outer}}" />', {
@@ -1127,7 +1127,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('non-block').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
});
- QUnit.skip('non-block with outer attributes replaced with a div shadows inner attributes', function() {
+ QUnit.test('non-block with outer attributes replaced with a div shadows inner attributes', function() {
registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />'); | true |
Other | emberjs | ember.js | ca436a2b1d4d488a6aeadd9ba7e6ab170e3a5e49.json | WIP: make regular elements like identity elements | packages/ember-template-compiler/lib/plugins/transform-top-level-components.js | @@ -9,14 +9,22 @@ function TransformTopLevelComponents() {
@param {AST} The AST to be transformed.
*/
TransformTopLevelComponents.prototype.transform = function TransformTopLevelComponents_transform(ast) {
+ let b = this.syntax.builders;
+
hasSingleComponentNode(ast.body, component => {
- component.tag = `@${component.tag}`;
+ if (component.type === 'ComponentNode') {
+ component.tag = `@${component.tag}`;
+ }
+ }, element => {
+ // TODO: Properly copy loc from children
+ let program = b.program(element.children);
+ return b.component(`@<${element.tag}>`, element.attributes, program, element.loc);
});
return ast;
};
-function hasSingleComponentNode(body, callback) {
+function hasSingleComponentNode(body, componentCallback, elementCallback) {
let lastComponentNode;
let lastIndex;
let nodeCount = 0;
@@ -39,7 +47,10 @@ function hasSingleComponentNode(body, callback) {
if (!lastComponentNode) { return; }
if (lastComponentNode.type === 'ComponentNode') {
- callback(lastComponentNode);
+ componentCallback(lastComponentNode);
+ } else {
+ let component = elementCallback(lastComponentNode);
+ body.splice(lastIndex, 1, component);
}
}
| true |
Other | emberjs | ember.js | ca436a2b1d4d488a6aeadd9ba7e6ab170e3a5e49.json | WIP: make regular elements like identity elements | packages/ember-views/lib/system/build-component-template.js | @@ -6,8 +6,8 @@ import { internal, render } from 'htmlbars-runtime';
import getValue from 'ember-htmlbars/hooks/get-value';
import { isStream } from 'ember-metal/streams/utils';
-export default function buildComponentTemplate({ component, layout, isAngleBracket, isComponentElement, outerAttrs }, attrs, content) {
- var blockToRender, tagName, meta;
+export default function buildComponentTemplate({ component, tagName, layout, isAngleBracket, isComponentElement, outerAttrs }, attrs, content) {
+ var blockToRender, meta;
if (component === undefined) {
component = null;
@@ -23,7 +23,7 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
}
if (component && !component._isAngleBracket || isComponentElement) {
- tagName = tagNameFor(component);
+ tagName = tagName || tagNameFor(component);
// If this is not a tagless component, we need to create the wrapping
// element. We use `manualElement` to create a template that represents | true |
Other | emberjs | ember.js | f2f09e8d12cc2c8e440eca0582cefd507c5a05a9.json | Skip failing tests for now
Also re-enabling a test that was actually fixed in the previous commit. | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -1043,7 +1043,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$().html(), '<div>This is a</div><div>fragment</div>', 'Just the fragment was used');
});
- QUnit.test('non-block without properties replaced with a div', function() {
+ QUnit.skip('non-block without properties replaced with a div', function() {
// The whitespace is added intentionally to verify that the heuristic is not "a single node" but
// rather "a single non-whitespace, non-comment node"
registry.register('template:components/non-block', compile(' <div>In layout</div> '));
@@ -1080,7 +1080,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equalsElement(node.firstElementChild, 'non-block', { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, 'In layout');
});
- QUnit.skip('non-block without properties replaced with identity element (regression if identity element has a single child element)', function() {
+ QUnit.test('non-block without properties replaced with identity element (regression if identity element has a single child element)', function() {
registry.register('template:components/non-block', compile('<non-block such="{{attrs.stability}}"><p>In layout</p></non-block>'));
view = appendViewFor('<non-block stability={{view.stability}} />', {
@@ -1089,17 +1089,17 @@ if (isEnabled('ember-htmlbars-component-generation')) {
let node = view.$()[0];
equal(view.$().text(), 'In layout');
- ok(view.$().html().match(/^<non-block id="[^"]*" such="stability" class="ember-view"><p>In layout<\/p><\/non-block>$/), 'The root element has gotten the default class and ids');
+ equalsElement(node.firstElementChild, 'non-block', { such: 'stability', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
ok(view.$('non-block.ember-view[id][such=stability]').length === 1, 'The non-block tag name was used');
- run(() => view.set('stability', 'stability!'));
+ run(() => view.set('stability', 'changed!!!'));
strictEqual(view.$()[0], node, 'the DOM node has remained stable');
equal(view.$().text(), 'In layout');
- ok(view.$().html().match(/^<non-block id="[^"]*" such="stability!" class="ember-view">In layout<\/non-block>$/), 'The root element has gotten the default class and ids');
+ equalsElement(node.firstElementChild, 'non-block', { such: 'changed!!!', class: 'ember-view', id: regex(/^ember\d*$/) }, '<p>In layout</p>');
});
- QUnit.test('non-block with class replaced with a div merges classes', function() {
+ QUnit.skip('non-block with class replaced with a div merges classes', function() {
registry.register('template:components/non-block', compile('<div class="inner-class" />'));
view = appendViewFor('<non-block class="{{view.outer}}" />', {
@@ -1127,7 +1127,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('non-block').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
});
- QUnit.test('non-block with outer attributes replaced with a div shadows inner attributes', function() {
+ QUnit.skip('non-block with outer attributes replaced with a div shadows inner attributes', function() {
registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
@@ -1159,7 +1159,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('non-block').attr('data-dynamic'), 'outer', 'the outer attribute wins');
});
- QUnit.test('non-block recurrsive invocations with outer attributes replaced with a div shadows inner attributes', function() {
+ QUnit.skip('non-block recursive invocations with outer attributes replaced with a div shadows inner attributes', function() {
registry.register('template:components/non-block-wrapper', compile('<non-block />'));
registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
@@ -1176,7 +1176,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
});
- QUnit.test('non-block recurrsive invocations with outer attributes replaced with identity element shadows inner attributes', function() {
+ QUnit.skip('non-block recursive invocations with outer attributes replaced with identity element shadows inner attributes', function() {
registry.register('template:components/non-block-wrapper', compile('<non-block />'));
registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
@@ -1193,7 +1193,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
});
- QUnit.test('non-block replaced with a div should have correct scope', function() {
+ QUnit.skip('non-block replaced with a div should have correct scope', function() {
registry.register('template:components/non-block', compile('<div>{{internal}}</div>'));
registry.register('component:non-block', GlimmerComponent.extend({ | false |
Other | emberjs | ember.js | d280c5353c3031272a3fda59e619e1d8f6fc6e02.json | Remove post-processing ("attributes") hook
This was previously used for attaching outer attributes as well as
system attributes (e.g. class="ember-view" id="ember123") onto regular
HTML elements at the root, once they have been rendered.
This results in multiple AttrNodes for a single attribute, which means
that there is no guarantee that any particular AttrNode will actually
"win". This incorrect strategy "works" a surprising amount of the time,
but the failure modes are unacceptable. (See new tests introduced in the
previous commit.)
This is in anticipation of making all top-level elements in a
component's layout dynamic, so that they can share attribute merging
logic with the "identity element" case (top-level `<my-component>` in
the layout for `my-component`). | packages/ember-htmlbars/lib/env.js | @@ -29,7 +29,6 @@ import lookupHelper from 'ember-htmlbars/hooks/lookup-helper';
import hasHelper from 'ember-htmlbars/hooks/has-helper';
import invokeHelper from 'ember-htmlbars/hooks/invoke-helper';
import element from 'ember-htmlbars/hooks/element';
-import attributes from 'ember-htmlbars/hooks/attributes';
import helpers from 'ember-htmlbars/helpers';
import keywords, { registerKeyword } from 'ember-htmlbars/keywords';
@@ -63,8 +62,7 @@ merge(emberHooks, {
lookupHelper,
hasHelper,
invokeHelper,
- element,
- attributes
+ element
});
import debuggerKeyword from 'ember-htmlbars/keywords/debugger'; | true |
Other | emberjs | ember.js | d280c5353c3031272a3fda59e619e1d8f6fc6e02.json | Remove post-processing ("attributes") hook
This was previously used for attaching outer attributes as well as
system attributes (e.g. class="ember-view" id="ember123") onto regular
HTML elements at the root, once they have been rendered.
This results in multiple AttrNodes for a single attribute, which means
that there is no guarantee that any particular AttrNode will actually
"win". This incorrect strategy "works" a surprising amount of the time,
but the failure modes are unacceptable. (See new tests introduced in the
previous commit.)
This is in anticipation of making all top-level elements in a
component's layout dynamic, so that they can share attribute merging
logic with the "identity element" case (top-level `<my-component>` in
the layout for `my-component`). | packages/ember-htmlbars/lib/hooks/attributes.js | @@ -1,50 +0,0 @@
-import { render, internal } from 'htmlbars-runtime';
-
-export default function attributes(morph, env, scope, template, parentNode, visitor) {
- let state = morph.state;
- let block = state.block;
-
- if (!block) {
- let element = findRootElement(parentNode);
- if (!element) { return; }
-
- normalizeClassStatement(template.statements, element);
-
- template.element = element;
- block = morph.state.block = internal.blockFor(render, template, { scope });
- }
-
- block(env, [], undefined, morph, undefined, visitor);
-}
-
-function normalizeClassStatement(statements, element) {
- let className = element.getAttribute('class');
- if (!className) { return; }
-
- for (let i = 0, l = statements.length; i < l; i++) {
- let statement = statements[i];
-
- if (statement[1] === 'class') {
- statement[2][2].unshift(className);
- }
- }
-}
-
-function findRootElement(parentNode) {
- let node = parentNode.firstChild;
- let found = null;
-
- while (node) {
- if (node.nodeType === 1) {
- // found more than one top-level element, so there is no "root element"
- if (found) { return null; }
- found = node;
- }
- node = node.nextSibling;
- }
-
- let className = found && found.getAttribute('class');
- if (!className || className.split(' ').indexOf('ember-view') === -1) {
- return found;
- }
-} | true |
Other | emberjs | ember.js | d280c5353c3031272a3fda59e619e1d8f6fc6e02.json | Remove post-processing ("attributes") hook
This was previously used for attaching outer attributes as well as
system attributes (e.g. class="ember-view" id="ember123") onto regular
HTML elements at the root, once they have been rendered.
This results in multiple AttrNodes for a single attribute, which means
that there is no guarantee that any particular AttrNode will actually
"win". This incorrect strategy "works" a surprising amount of the time,
but the failure modes are unacceptable. (See new tests introduced in the
previous commit.)
This is in anticipation of making all top-level elements in a
component's layout dynamic, so that they can share attribute merging
logic with the "identity element" case (top-level `<my-component>` in
the layout for `my-component`). | packages/ember-views/lib/system/build-component-template.js | @@ -1,5 +1,6 @@
import Ember from 'ember-metal/core';
import { get } from 'ember-metal/property_get';
+import assign from 'ember-metal/assign';
import { isGlobal } from 'ember-metal/path_cache';
import { internal, render } from 'htmlbars-runtime';
import getValue from 'ember-htmlbars/hooks/get-value';
@@ -13,10 +14,8 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
}
if (layout && layout.raw) {
- let attributes = (component && component._isAngleBracket) ? normalizeComponentAttributes(component, true, attrs) : undefined;
-
let yieldTo = createContentBlocks(content.templates, content.scope, content.self, component);
- blockToRender = createLayoutBlock(layout.raw, yieldTo, content.self, component, attrs, attributes);
+ blockToRender = createLayoutBlock(layout.raw, yieldTo, content.self, component, attrs);
meta = layout.raw.meta;
} else if (content.templates && content.templates.default) {
blockToRender = createContentBlock(content.templates.default, content.scope, content.self, component);
@@ -30,14 +29,8 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
// element. We use `manualElement` to create a template that represents
// the wrapping element and yields to the previous block.
if (tagName !== '') {
- let attributes;
-
- if (isComponentElement) {
- attributes = convertAttrsToAst(attrs);
- } else {
- attributes = normalizeComponentAttributes(component, isAngleBracket, attrs);
- }
-
+ if (isComponentElement) { attrs = mergeAttrs(attrs, outerAttrs); }
+ var attributes = normalizeComponentAttributes(component, isAngleBracket, attrs);
var elementTemplate = internal.manualElement(tagName, attributes);
elementTemplate.meta = meta;
@@ -54,18 +47,27 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
return { createdElement: !!tagName, block: blockToRender };
}
+function mergeAttrs(innerAttrs, outerAttrs) {
+ let result = assign({}, innerAttrs, outerAttrs);
+
+ if (innerAttrs.class && outerAttrs.class) {
+ result.class = ['subexpr', '-join-classes', [['value', innerAttrs.class], ['value', outerAttrs.class]], []];
+ }
+
+ return result;
+}
+
function blockFor(template, options) {
Ember.assert('BUG: Must pass a template to blockFor', !!template);
return internal.blockFor(render, template, options);
}
-function createContentBlock(template, scope, self, component, attributes) {
+function createContentBlock(template, scope, self, component) {
Ember.assert('BUG: buildComponentTemplate can take a scope or a self, but not both', !(scope && self));
return blockFor(template, {
scope,
self,
- attributes,
options: { view: component }
});
}
@@ -86,10 +88,9 @@ function createContentBlocks(templates, scope, self, component) {
return output;
}
-function createLayoutBlock(template, yieldTo, self, component, attrs, attributes) {
+function createLayoutBlock(template, yieldTo, self, component, attrs) {
return blockFor(template, {
yieldTo,
- attributes,
// If we have an old-style Controller with a template it will be
// passed as our `self` argument, and it should be the context for
@@ -126,23 +127,6 @@ function tagNameFor(view) {
return tagName;
}
-function convertAttrsToAst(attrs) {
- let normalized = {};
-
- for (var prop in attrs) {
- let val = attrs[prop];
- if (!val) { continue; }
-
- if (typeof val === 'string') {
- normalized[prop] = val;
- } else if (val.isConcat) {
- normalized[prop] = ['value', val];
- }
- }
-
- return normalized;
-}
-
// Takes a component and builds a normalized set of attribute
// bindings consumable by HTMLBars' `attribute` hook.
function normalizeComponentAttributes(component, isAngleBracket, attrs) { | true |
Other | emberjs | ember.js | 205a393af9b669e78e3ca196515a453c3d0cdaf0.json | Update QUnit to 1.18.0.
Also includes an update to emberjs-build to ensure the static test page
that is generated contains the correct QUnit version. | bower.json | @@ -6,7 +6,7 @@
},
"dependencies": {
"jquery": "~1.11.1",
- "qunit": "~1.17.1",
+ "qunit": "~1.18.0",
"qunit-phantom-runner": "jonkemp/qunit-phantomjs-runner#1.2.0"
},
"devDependencies": { | true |
Other | emberjs | ember.js | 205a393af9b669e78e3ca196515a453c3d0cdaf0.json | Update QUnit to 1.18.0.
Also includes an update to emberjs-build to ensure the static test page
that is generated contains the correct QUnit version. | package.json | @@ -27,7 +27,7 @@
"ember-cli-sauce": "^1.3.0",
"ember-cli-yuidoc": "0.7.0",
"ember-publisher": "0.0.7",
- "emberjs-build": "0.2.5",
+ "emberjs-build": "0.2.6",
"express": "^4.5.0",
"finalhandler": "^0.4.0",
"github": "^0.2.3", | true |
Other | emberjs | ember.js | a668299bc8dcc922617718d9dc4b63152413cef2.json | Add some new (failing) tests for component bugs | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -1113,7 +1113,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('div').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
});
- QUnit.test('non-block with class replaced with a identity element merges classes', function() {
+ QUnit.test('non-block with class replaced with identity element merges classes', function() {
registry.register('template:components/non-block', compile('<non-block class="inner-class" />'));
view = appendViewFor('<non-block class="{{view.outer}}" />', {
@@ -1127,6 +1127,134 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('non-block').attr('class'), 'inner-class new-outer ember-view', 'the classes are merged');
});
+ QUnit.test('non-block with outer attributes replaced with a div shadows inner attributes', function() {
+ registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
+
+ view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer attribute wins');
+
+ let component = view.childViews[0]; // HAX
+
+ run(() => component.set('internal', 'changed'));
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer attribute wins');
+ });
+
+ QUnit.test('non-block with outer attributes replaced with identity element shadows inner attributes', function() {
+ registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
+
+ view = appendViewFor('<non-block data-static="outer" data-dynamic="outer" />');
+
+ equal(view.$('non-block').attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$('non-block').attr('data-dynamic'), 'outer', 'the outer attribute wins');
+
+ let component = view.childViews[0]; // HAX
+
+ run(() => component.set('internal', 'changed'));
+
+ equal(view.$('non-block').attr('data-static'), 'outer', 'the outer attribute wins');
+ equal(view.$('non-block').attr('data-dynamic'), 'outer', 'the outer attribute wins');
+ });
+
+ QUnit.test('non-block recurrsive invocations with outer attributes replaced with a div shadows inner attributes', function() {
+ registry.register('template:components/non-block-wrapper', compile('<non-block />'));
+ registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
+
+ view = appendViewFor('<non-block-wrapper data-static="outer" data-dynamic="outer" />');
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+
+ let component = view.childViews[0].childViews[0]; // HAX
+
+ run(() => component.set('internal', 'changed'));
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+ });
+
+ QUnit.test('non-block recurrsive invocations with outer attributes replaced with identity element shadows inner attributes', function() {
+ registry.register('template:components/non-block-wrapper', compile('<non-block />'));
+ registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
+
+ view = appendViewFor('<non-block-wrapper data-static="outer" data-dynamic="outer" />');
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+
+ let component = view.childViews[0].childViews[0]; // HAX
+
+ run(() => component.set('internal', 'changed'));
+
+ equal(view.$('div').attr('data-static'), 'outer', 'the outer-most attribute wins');
+ equal(view.$('div').attr('data-dynamic'), 'outer', 'the outer-most attribute wins');
+ });
+
+ QUnit.test('non-block replaced with a div should have correct scope', function() {
+ registry.register('template:components/non-block', compile('<div>{{internal}}</div>'));
+
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
+
+ view = appendViewFor('<non-block />');
+
+ equal(view.$().text(), 'stuff');
+ });
+
+ QUnit.test('non-block replaced with identity element should have correct scope', function() {
+ registry.register('template:components/non-block', compile('<non-block>{{internal}}</non-block>'));
+
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
+
+ view = appendViewFor('<non-block />');
+
+ equal(view.$().text(), 'stuff');
+ });
+
+ QUnit.test('non-block replaced with a div should have inner attributes', function() {
+ registry.register('template:components/non-block', compile('<div data-static="static" data-dynamic="{{internal}}" />'));
+
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
+
+ view = appendViewFor('<non-block />');
+
+ equal(view.$('div').attr('data-static'), 'static');
+ equal(view.$('div').attr('data-dynamic'), 'stuff');
+ });
+
+ QUnit.test('non-block replaced with identity element should have inner attributes', function() {
+ registry.register('template:components/non-block', compile('<non-block data-static="static" data-dynamic="{{internal}}" />'));
+
+ registry.register('component:non-block', GlimmerComponent.extend({
+ init() {
+ this._super(...arguments);
+ this.set('internal', 'stuff');
+ }
+ }));
+
+ view = appendViewFor('<non-block />');
+
+ equal(view.$('non-block').attr('data-static'), 'static');
+ equal(view.$('non-block').attr('data-dynamic'), 'stuff');
+ });
+
QUnit.test('non-block rendering a fragment', function() {
registry.register('template:components/non-block', compile('<p>{{attrs.first}}</p><p>{{attrs.second}}</p>'));
@@ -1153,7 +1281,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$('with-block.ember-view').text(), 'In layout - In template', 'Both the layout and template are rendered');
});
- QUnit.test('non-block with properties on attrs', function() {
+ QUnit.test('non-block with properties on attrs', function() {
registry.register('template:components/non-block', compile('<non-block>In layout</non-block>'));
view = appendViewFor('<non-block static-prop="static text" concat-prop="{{view.dynamic}} text" dynamic-prop={{view.dynamic}} />', { | false |
Other | emberjs | ember.js | 361990401342186150f43004eb35f2a83dfc3789.json | Remove incorrect attributes
This code was previously telling HTMLBars to post-process content
templates to add top-level attributes. That is not correct (it only
makes sense to post-process layouts). | packages/ember-views/lib/system/build-component-template.js | @@ -20,8 +20,7 @@ export default function buildComponentTemplate({ component, layout, isAngleBrack
blockToRender = createLayoutBlock(layout.raw, yieldTo, content.self, component, attrs, attributes);
meta = layout.raw.meta;
} else if (content.templates && content.templates.default) {
- let attributes = (component && component._isAngleBracket) ? normalizeComponentAttributes(component, true, attrs) : undefined;
- blockToRender = createContentBlock(content.templates.default, content.scope, content.self, component, attributes);
+ blockToRender = createContentBlock(content.templates.default, content.scope, content.self, component);
meta = content.templates.default.meta;
}
| false |
Other | emberjs | ember.js | 912392ea5d7d5bb607c0914c40b5810dbef3d4bd.json | Show error for component class/invocation mismatch
1. {{my-component ...}} curly braces can only be used on legacy Component
2. <my-component ...> angle brackets can only be used on GlimmerComponent
TBD: rule number 2 might be loosened with an explicit opt-in later,
depending on how painful this transition turns out to be for large apps.
It might be better to provide automated rewriting through ember-watson,
which would do the job quickly, once and for all, rather than leaving
large apps in a semantic limbo with one foot in the old world and
another foot in the new world. | packages/ember-htmlbars/lib/node-managers/component-node-manager.js | @@ -9,7 +9,8 @@ import setProperties from 'ember-metal/set_properties';
import { MUTABLE_CELL } from 'ember-views/compat/attrs-proxy';
import SafeString from 'htmlbars-util/safe-string';
import { instrument } from 'ember-htmlbars/system/instrumentation-support';
-import EmberComponent from 'ember-views/components/component';
+import LegacyEmberComponent from 'ember-views/components/component';
+import GlimmerComponent from 'ember-htmlbars/glimmer-component';
import Stream from 'ember-metal/streams/stream';
import { readArray } from 'ember-metal/streams/utils';
@@ -50,7 +51,7 @@ ComponentNodeManager.create = function(renderNode, env, options) {
return component || layout;
});
- component = component || EmberComponent;
+ component = component || (isAngleBracket ? GlimmerComponent : LegacyEmberComponent);
let createOptions = { parentView };
@@ -80,6 +81,14 @@ ComponentNodeManager.create = function(renderNode, env, options) {
// Instantiate the component
component = createComponent(component, isAngleBracket, createOptions, renderNode, env, attrs, proto);
+ Ember.runInDebug(() => {
+ if (isAngleBracket) {
+ Ember.assert(`You cannot invoke the '${tagName}' component with angle brackets, because it's a subclass of Component. Please upgrade to GlimmerComponent. Alternatively, you can invoke as '{{${tagName}}}'.`, component.isGlimmerComponent);
+ } else {
+ Ember.assert(`You cannot invoke the '${tagName}' component with curly braces, because it's a subclass of GlimmerComponent. Please invoke it as '<${tagName}>' instead.`, !component.isGlimmerComponent);
+ }
+ });
+
// If the component specifies its template via the `layout` or `template`
// properties instead of using the template looked up in the container, get
// them now that we have the component instance. | true |
Other | emberjs | ember.js | 912392ea5d7d5bb607c0914c40b5810dbef3d4bd.json | Show error for component class/invocation mismatch
1. {{my-component ...}} curly braces can only be used on legacy Component
2. <my-component ...> angle brackets can only be used on GlimmerComponent
TBD: rule number 2 might be loosened with an explicit opt-in later,
depending on how painful this transition turns out to be for large apps.
It might be better to provide automated rewriting through ember-watson,
which would do the job quickly, once and for all, rather than leaving
large apps in a semantic limbo with one foot in the old world and
another foot in the new world. | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -65,6 +65,15 @@ QUnit.test('non-block without properties', function() {
equal(jQuery('#qunit-fixture').text(), 'In layout');
});
+QUnit.test('GlimmerComponent cannot be invoked with curly braces', function() {
+ registry.register('template:components/non-block', compile('In layout'));
+ registry.register('component:non-block', GlimmerComponent.extend());
+
+ expectAssertion(function() {
+ view = appendViewFor('{{non-block}}');
+ }, /cannot invoke the 'non-block' component with curly braces/);
+});
+
QUnit.test('block without properties', function() {
expect(1);
@@ -1017,6 +1026,15 @@ if (isEnabled('ember-htmlbars-component-generation')) {
equal(view.$().html(), 'In layout', 'Just the fragment was used');
});
+ QUnit.test('legacy components cannot be invoked with angle brackets', function() {
+ registry.register('template:components/non-block', compile('In layout'));
+ registry.register('component:non-block', Component.extend());
+
+ expectAssertion(function() {
+ view = appendViewFor('<non-block />');
+ }, /cannot invoke the 'non-block' component with angle brackets/);
+ });
+
QUnit.test('non-block without properties replaced with a fragment when the content is multiple elements', function() {
registry.register('template:components/non-block', compile('<div>This is a</div><div>fragment</div>'));
@@ -1175,6 +1193,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
registry.register('template:components/non-block', compile('<non-block>In layout - someProp: {{attrs.someProp}}</non-block>'));
view = appendViewFor('<non-block someProp="something here" />');
+ console.log(jQuery('#qunit-fixture').html());
equal(jQuery('#qunit-fixture').text(), 'In layout - someProp: something here');
});
@@ -1234,7 +1253,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
moduleName: layoutModuleName
});
registry.register('template:components/sample-component', sampleComponentLayout);
- registry.register('component:sample-component', Component.extend({
+ registry.register('component:sample-component', GlimmerComponent.extend({
didInsertElement: function() {
equal(this._renderNode.lastResult.template.meta.moduleName, layoutModuleName);
} | true |
Other | emberjs | ember.js | 8dc7d58cd4c0f45cc5aaf79c3ccf03d10dd7445f.json | Fix attr setting in Glimmer Components
Previously, Glimmer components got their attrs set after positional
attrs were applied. The `didInitAttrs` hook was used to indicate that
the full set of attributes were applied.
Recently, positional attrs were changed to ensure that the full set of
attrs are always applied before `init`, eliminating the need for
`didInitAttrs`.
However, the existing code that applied attrs on init only did so for
non-angle bracket components (to avoid double-setting on new-world
features). Consequently, angle bracket components *never* got their
attrs set.
This commit ensures that `attrs` are set on all components before init,
regardless of style. | packages/ember-htmlbars/lib/node-managers/component-node-manager.js | @@ -301,13 +301,13 @@ ComponentNodeManager.prototype.destroy = function() {
export function createComponent(_component, isAngleBracket, _props, renderNode, env, attrs = {}, proto = _component.proto()) {
let props = assign({}, _props);
+ let snapshot = takeSnapshot(attrs);
+ props.attrs = snapshot;
+
if (!isAngleBracket) {
let hasSuppliedController = 'controller' in attrs; // 2.0TODO remove
Ember.deprecate('controller= is deprecated', !hasSuppliedController, { id: 'ember-htmlbars.create-component', until: '3.0.0' });
- let snapshot = takeSnapshot(attrs);
- props.attrs = snapshot;
-
mergeBindings(props, shadowedAttrs(proto, snapshot));
} else {
props._isAngleBracket = true; | false |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/lib/glimmer-component.js | @@ -1,5 +1,25 @@
-import EmberObject from "ember-runtime/system/object";
+import CoreView from 'ember-views/views/core_view';
+import ViewChildViewsSupport from 'ember-views/mixins/view_child_views_support';
+import ViewStateSupport from 'ember-views/mixins/view_state_support';
+import TemplateRenderingSupport from 'ember-views/mixins/template_rendering_support';
+import ClassNamesSupport from 'ember-views/mixins/class_names_support';
+import InstrumentationSupport from 'ember-views/mixins/instrumentation_support';
+import AriaRoleSupport from 'ember-views/mixins/aria_role_support';
+import ViewMixin from 'ember-views/mixins/view_support';
+import EmberView from 'ember-views/views/view';
-export default EmberObject.extend({
+export default CoreView.extend(
+ ViewChildViewsSupport,
+ ViewStateSupport,
+ TemplateRenderingSupport,
+ ClassNamesSupport,
+ InstrumentationSupport,
+ AriaRoleSupport,
+ ViewMixin, {
+ isGlimmerComponent: true,
-});
+ init() {
+ this._super(...arguments);
+ this._viewRegistry = this._viewRegistry || EmberView.views;
+ }
+ }); | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/lib/hooks/bind-self.js | @@ -19,7 +19,13 @@ export default function bindSelf(env, scope, _self) {
if (self && self.isView) {
newStream(scope.locals, 'view', self, null);
newStream(scope.locals, 'controller', scope.locals.view.getKey('controller'));
- newStream(scope, 'self', scope.locals.view.getKey('context'), null, true);
+
+ if (self.isGlimmerComponent) {
+ newStream(scope, 'self', self, null, true);
+ } else {
+ newStream(scope, 'self', scope.locals.view.getKey('context'), null, true);
+ }
+
return;
}
| true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/lib/main.js | @@ -54,6 +54,7 @@ import legacyEachWithKeywordHelper from 'ember-htmlbars/helpers/-legacy-each-wit
import htmlSafeHelper from 'ember-htmlbars/helpers/-html-safe';
import DOMHelper from 'ember-htmlbars/system/dom-helper';
import Helper, { helper as makeHelper } from 'ember-htmlbars/helper';
+import GlimmerComponent from 'ember-htmlbars/glimmer-component';
// importing adds template bootstrapping
// initializer to enable embedded templates
@@ -91,6 +92,8 @@ Ember.HTMLBars = {
DOMHelper
};
+Ember.GlimmerComponent = GlimmerComponent;
+
if (isEnabled('ember-htmlbars-helper')) {
Helper.helper = makeHelper;
Ember.Helper = Helper; | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/tests/glimmer-component/render-test.js | @@ -1,32 +1,34 @@
-import Registry from "container/registry";
-import View from "ember-views/views/view";
-import GlimmerComponent from "ember-htmlbars/glimmer-component";
+import Registry from 'container/registry';
+import View from 'ember-views/views/view';
+import GlimmerComponent from 'ember-htmlbars/glimmer-component';
import compile from 'ember-template-compiler/system/compile';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
+import ComponentLookup from 'ember-views/component_lookup';
let view;
-QUnit.module("A basic glimmer component", {
+QUnit.module('A basic glimmer component', {
teardown() {
runDestroy(view);
}
});
function renderComponent(tag, component) {
- let { params, hash, implementation } = component;
+ let { params, hash, yielded, implementation } = component;
params = params || [];
hash = hash || {};
- let stringParams = params.join(" ");
+ let stringParams = params.join(' ');
let stringHash = Object.keys(hash)
.map(key => `${key}=${hash[key]}`)
.join(' ');
let registry = new Registry();
+ registry.register('component-lookup:main', ComponentLookup);
registry.register(`component:${tag}`, implementation);
view = View.extend({
container: registry.container(),
- template: compile(`{{debugger}}<${tag} ${stringParams} ${stringHash}></${tag}>`)
+ template: compile(`<${tag} ${stringParams} ${stringHash}>${yielded}</${tag}>`)
}).create();
runAppend(view);
@@ -36,28 +38,30 @@ function hasSelector(assert, selector) {
assert.ok(document.querySelector(`#qunit-fixture ${selector}`), `${selector} exists`);
}
-QUnit.test("it renders", function(assert) {
+QUnit.test('it renders', function(assert) {
let component;
let MyComponent = GlimmerComponent.extend({
init() {
component = this;
this._super(...arguments);
- }
+ },
+ layout: compile(`<my-component>{{yield}}</my-component>`)
});
renderComponent('my-component', {
- implementation: MyComponent
+ implementation: MyComponent,
+ yielded: 'Hello world'
});
ok(component instanceof GlimmerComponent, 'the component was instantiated correctly');
equal(view.childViews[0], component, 'the component was rendered and inserted into child views');
- hasSelector(assert, 'my-component');
+ hasSelector(assert, `my-component.ember-view[id=${component.elementId}]`);
});
//testForComponent({
- //name: "my-component",
+ //name: 'my-component',
//params: [],
//hash: {},
//template: ` | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/tests/glimmer-component/test-helpers.js | @@ -1,11 +1,9 @@
export function moduleForGlimmerComponent(name, options) {
- let beforeEach = () => {
-
- };
+ function beforeEach() {
+ }
- let afterEach = () => {
-
- };
+ function afterEach() {
+ }
QUnit.module(`Glimmer Component - ${name}`, { beforeEach, afterEach });
} | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/tests/integration/component_invocation_test.js | @@ -6,6 +6,7 @@ import jQuery from 'ember-views/system/jquery';
import compile from 'ember-template-compiler/system/compile';
import ComponentLookup from 'ember-views/component_lookup';
import Component from 'ember-views/components/component';
+import GlimmerComponent from 'ember-htmlbars/glimmer-component';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
@@ -1131,11 +1132,11 @@ if (isEnabled('ember-htmlbars-component-generation')) {
//equal(jQuery('#qunit-fixture').text(), 'In layout - someProp: something here');
});
- QUnit.skip('attributes are not installed on the top level', function() {
+ QUnit.test('attributes are not installed on the top level', function() {
let component;
- registry.register('template:components/non-block', compile('<non-block>In layout - {{attrs.text}} -- {{text}}</non-block>'));
- registry.register('component:non-block', Component.extend({
+ registry.register('template:components/non-block', compile('<non-block>In layout - {{attrs.text}}</non-block>'));
+ registry.register('component:non-block', GlimmerComponent.extend({
text: null,
dynamic: null,
@@ -1166,8 +1167,8 @@ if (isEnabled('ember-htmlbars-component-generation')) {
strictEqual(get(component, 'dynamic'), null);
});
- QUnit.test('non-block with properties on attrs and component class', function() {
- registry.register('component:non-block', Component.extend());
+ QUnit.test('non-block with properties on attrs and component class', function() {
+ registry.register('component:non-block', GlimmerComponent.extend());
registry.register('template:components/non-block', compile('<non-block>In layout - someProp: {{attrs.someProp}}</non-block>'));
view = appendViewFor('<non-block someProp="something here" />');
@@ -1179,7 +1180,7 @@ if (isEnabled('ember-htmlbars-component-generation')) {
var willUpdate = 0;
var didReceiveAttrs = 0;
- registry.register('component:non-block', Component.extend({
+ registry.register('component:non-block', GlimmerComponent.extend({
didReceiveAttrs() {
didReceiveAttrs++;
}, | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-htmlbars/tests/integration/component_lifecycle_test.js | @@ -3,344 +3,381 @@ import jQuery from 'ember-views/system/jquery';
import compile from 'ember-template-compiler/system/compile';
import ComponentLookup from 'ember-views/component_lookup';
import Component from 'ember-views/components/component';
+import GlimmerComponent from 'ember-htmlbars/glimmer-component';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import run from 'ember-metal/run_loop';
import EmberView from 'ember-views/views/view';
var registry, container, view;
var hooks;
-QUnit.module('component - lifecycle hooks', {
- setup() {
- registry = new Registry();
- container = registry.container();
- registry.optionsForType('component', { singleton: false });
- registry.optionsForType('view', { singleton: false });
- registry.optionsForType('template', { instantiate: false });
- registry.register('component-lookup:main', ComponentLookup);
-
- hooks = [];
- },
-
- teardown() {
- runDestroy(container);
- runDestroy(view);
- registry = container = view = null;
+let styles = [{
+ name: 'curly',
+ class: Component
+}, {
+ name: 'angle',
+ class: GlimmerComponent
+}];
+
+styles.forEach(style => {
+ function invoke(name, hash) {
+ if (style.name === 'curly') {
+ let attrs = Object.keys(hash).map(k => `${k}=${val(hash[k])}`).join(' ');
+ return `{{${name} ${attrs}}}`;
+ } else if (style.name === 'angle') {
+ let attrs = Object.keys(hash).map(k => `${k}=${val(hash[k])}`).join(' ');
+ return `<${name} ${attrs} />`;
+ }
}
-});
-
-function pushHook(view, type, arg) {
- hooks.push(hook(view, type, arg));
-}
-
-function hook(view, type, arg) {
- return { type: type, view: view, arg: arg };
-}
-
-QUnit.test('lifecycle hooks are invoked in a predictable order', function() {
- var components = {};
- function component(label) {
- return Component.extend({
- init() {
- this.label = label;
- components[label] = this;
- this._super.apply(this, arguments);
- },
-
- didInitAttrs(options) {
- pushHook(label, 'didInitAttrs', options);
- },
+ function val(value) {
+ if (value.isString) {
+ return JSON.stringify(value.value);
+ }
- didUpdateAttrs(options) {
- pushHook(label, 'didUpdateAttrs', options);
- },
+ if (style.name === 'curly') {
+ return `(readonly ${value})`;
+ } else {
+ return `{{${value}}}`;
+ }
+ }
- willUpdate(options) {
- pushHook(label, 'willUpdate', options);
- },
+ function string(val) {
+ return { isString: true, value: val };
+ }
- didReceiveAttrs(options) {
- pushHook(label, 'didReceiveAttrs', options);
- },
+ QUnit.module(`component - lifecycle hooks (${style.name})`, {
+ setup() {
+ registry = new Registry();
+ container = registry.container();
+ registry.optionsForType('component', { singleton: false });
+ registry.optionsForType('view', { singleton: false });
+ registry.optionsForType('template', { instantiate: false });
+ registry.register('component-lookup:main', ComponentLookup);
+
+ hooks = [];
+ },
+
+ teardown() {
+ runDestroy(container);
+ runDestroy(view);
+ registry = container = view = null;
+ }
+ });
- willRender() {
- pushHook(label, 'willRender');
- },
+ function pushHook(view, type, arg) {
+ hooks.push(hook(view, type, arg));
+ }
- didRender() {
- pushHook(label, 'didRender');
- },
+ function hook(view, type, arg) {
+ return { type: type, view: view, arg: arg };
+ }
- didInsertElement() {
- pushHook(label, 'didInsertElement');
- },
+ QUnit.test('lifecycle hooks are invoked in a predictable order', function() {
+ var components = {};
+
+ function component(label) {
+ return style.class.extend({
+ init() {
+ this.label = label;
+ components[label] = this;
+ this._super.apply(this, arguments);
+ },
+
+ didInitAttrs(options) {
+ pushHook(label, 'didInitAttrs', options);
+ },
+
+ didUpdateAttrs(options) {
+ pushHook(label, 'didUpdateAttrs', options);
+ },
+
+ willUpdate(options) {
+ pushHook(label, 'willUpdate', options);
+ },
+
+ didReceiveAttrs(options) {
+ pushHook(label, 'didReceiveAttrs', options);
+ },
+
+ willRender() {
+ pushHook(label, 'willRender');
+ },
+
+ didRender() {
+ pushHook(label, 'didRender');
+ },
+
+ didInsertElement() {
+ pushHook(label, 'didInsertElement');
+ },
+
+ didUpdate(options) {
+ pushHook(label, 'didUpdate', options);
+ }
+ });
+ }
- didUpdate(options) {
- pushHook(label, 'didUpdate', options);
- }
- });
- }
+ registry.register('component:the-top', component('top'));
+ registry.register('component:the-middle', component('middle'));
+ registry.register('component:the-bottom', component('bottom'));
- registry.register('component:the-top', component('top'));
- registry.register('component:the-middle', component('middle'));
- registry.register('component:the-bottom', component('bottom'));
+ registry.register('template:components/the-top', compile(`Twitter: {{attrs.twitter}} ${invoke('the-middle', { name: string('Tom Dale') })}`));
+ registry.register('template:components/the-middle', compile(`Name: {{attrs.name}} ${invoke('the-bottom', { website: string('tomdale.net') })}`));
+ registry.register('template:components/the-bottom', compile('Website: {{attrs.website}}'));
- registry.register('template:components/the-top', compile('Twitter: {{attrs.twitter}} {{the-middle name="Tom Dale"}}'));
- registry.register('template:components/the-middle', compile('Name: {{attrs.name}} {{the-bottom website="tomdale.net"}}'));
- registry.register('template:components/the-bottom', compile('Website: {{attrs.website}}'));
+ view = EmberView.extend({
+ template: compile(invoke('the-top', { twitter: 'view.twitter' })),
+ twitter: '@tomdale',
+ container: container
+ }).create();
- view = EmberView.extend({
- template: compile('{{the-top twitter=(readonly view.twitter)}}'),
- twitter: '@tomdale',
- container: container
- }).create();
+ runAppend(view);
- runAppend(view);
+ ok(component, 'The component was inserted');
+ equal(jQuery('#qunit-fixture').text(), 'Twitter: @tomdale Name: Tom Dale Website: tomdale.net');
- ok(component, 'The component was inserted');
- equal(jQuery('#qunit-fixture').text(), 'Twitter: @tomdale Name: Tom Dale Website: tomdale.net');
+ let topAttrs = { twitter: '@tomdale' };
+ let middleAttrs = { name: 'Tom Dale' };
+ let bottomAttrs = { website: 'tomdale.net' };
- let topAttrs = { twitter: '@tomdale' };
- let middleAttrs = { name: 'Tom Dale' };
- let bottomAttrs = { website: 'tomdale.net' };
+ deepEqual(hooks, [
+ hook('top', 'didInitAttrs', { attrs: topAttrs }), hook('top', 'didReceiveAttrs', { newAttrs: topAttrs }), hook('top', 'willRender'),
+ hook('middle', 'didInitAttrs', { attrs: middleAttrs }), hook('middle', 'didReceiveAttrs', { newAttrs: middleAttrs }), hook('middle', 'willRender'),
+ hook('bottom', 'didInitAttrs', { attrs: bottomAttrs }), hook('bottom', 'didReceiveAttrs', { newAttrs: bottomAttrs }), hook('bottom', 'willRender'),
+ hook('bottom', 'didInsertElement'), hook('bottom', 'didRender'),
+ hook('middle', 'didInsertElement'), hook('middle', 'didRender'),
+ hook('top', 'didInsertElement'), hook('top', 'didRender')
+ ]);
- deepEqual(hooks, [
- hook('top', 'didInitAttrs', { attrs: topAttrs }), hook('top', 'didReceiveAttrs', { newAttrs: topAttrs }), hook('top', 'willRender'),
- hook('middle', 'didInitAttrs', { attrs: middleAttrs }), hook('middle', 'didReceiveAttrs', { newAttrs: middleAttrs }), hook('middle', 'willRender'),
- hook('bottom', 'didInitAttrs', { attrs: bottomAttrs }), hook('bottom', 'didReceiveAttrs', { newAttrs: bottomAttrs }), hook('bottom', 'willRender'),
- hook('bottom', 'didInsertElement'), hook('bottom', 'didRender'),
- hook('middle', 'didInsertElement'), hook('middle', 'didRender'),
- hook('top', 'didInsertElement'), hook('top', 'didRender')
- ]);
+ hooks = [];
- hooks = [];
+ run(function() {
+ components.bottom.rerender();
+ });
- run(function() {
- components.bottom.rerender();
- });
+ deepEqual(hooks, [
+ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'didUpdate'), hook('bottom', 'didRender')
+ ]);
- deepEqual(hooks, [
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
- hook('bottom', 'didUpdate'), hook('bottom', 'didRender')
- ]);
+ hooks = [];
- hooks = [];
+ run(function() {
+ components.middle.rerender();
+ });
- run(function() {
- components.middle.rerender();
- });
+ bottomAttrs = { oldAttrs: { website: 'tomdale.net' }, newAttrs: { website: 'tomdale.net' } };
- bottomAttrs = { oldAttrs: { website: 'tomdale.net' }, newAttrs: { website: 'tomdale.net' } };
+ deepEqual(hooks, [
+ hook('middle', 'willUpdate'), hook('middle', 'willRender'),
- deepEqual(hooks, [
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ hook('bottom', 'didUpdateAttrs', bottomAttrs),
+ hook('bottom', 'didReceiveAttrs', bottomAttrs),
- hook('bottom', 'didUpdateAttrs', bottomAttrs),
- hook('bottom', 'didReceiveAttrs', bottomAttrs),
+ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
+ hook('middle', 'didUpdate'), hook('middle', 'didRender')
+ ]);
- hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
- hook('middle', 'didUpdate'), hook('middle', 'didRender')
- ]);
+ hooks = [];
- hooks = [];
+ run(function() {
+ components.top.rerender();
+ });
- run(function() {
- components.top.rerender();
- });
+ middleAttrs = { oldAttrs: { name: 'Tom Dale' }, newAttrs: { name: 'Tom Dale' } };
- middleAttrs = { oldAttrs: { name: 'Tom Dale' }, newAttrs: { name: 'Tom Dale' } };
+ deepEqual(hooks, [
+ hook('top', 'willUpdate'), hook('top', 'willRender'),
- deepEqual(hooks, [
- hook('top', 'willUpdate'), hook('top', 'willRender'),
+ hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
+ hook('middle', 'willUpdate'), hook('middle', 'willRender'),
- hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
+ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
- hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
- hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
+ hook('middle', 'didUpdate'), hook('middle', 'didRender'),
+ hook('top', 'didUpdate'), hook('top', 'didRender')
+ ]);
- hook('middle', 'didUpdate'), hook('middle', 'didRender'),
- hook('top', 'didUpdate'), hook('top', 'didRender')
- ]);
+ hooks = [];
- hooks = [];
+ run(function() {
+ view.set('twitter', '@hipstertomdale');
+ });
- run(function() {
- view.set('twitter', '@hipstertomdale');
+ // Because the `twitter` attr is only used by the topmost component,
+ // and not passed down, we do not expect to see lifecycle hooks
+ // called for child components. If the `didReceiveAttrs` hook used
+ // the new attribute to rerender itself imperatively, that would result
+ // in lifecycle hooks being invoked for the child.
+
+ deepEqual(hooks, [
+ hook('top', 'didUpdateAttrs', { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } }),
+ hook('top', 'didReceiveAttrs', { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } }),
+ hook('top', 'willUpdate'),
+ hook('top', 'willRender'),
+ hook('top', 'didUpdate'), hook('top', 'didRender')
+ ]);
});
- // Because the `twitter` attr is only used by the topmost component,
- // and not passed down, we do not expect to see lifecycle hooks
- // called for child components. If the `didReceiveAttrs` hook used
- // the new attribute to rerender itself imperatively, that would result
- // in lifecycle hooks being invoked for the child.
-
- deepEqual(hooks, [
- hook('top', 'didUpdateAttrs', { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } }),
- hook('top', 'didReceiveAttrs', { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } }),
- hook('top', 'willUpdate'),
- hook('top', 'willRender'),
- hook('top', 'didUpdate'), hook('top', 'didRender')
- ]);
-});
-
-QUnit.test('passing values through attrs causes lifecycle hooks to fire if the attribute values have changed', function() {
- var components = {};
+ QUnit.test('passing values through attrs causes lifecycle hooks to fire if the attribute values have changed', function() {
+ var components = {};
+
+ function component(label) {
+ return style.class.extend({
+ init() {
+ this.label = label;
+ components[label] = this;
+ this._super.apply(this, arguments);
+ },
+
+ didInitAttrs(options) {
+ pushHook(label, 'didInitAttrs', options);
+ },
+
+ didUpdateAttrs(options) {
+ pushHook(label, 'didUpdateAttrs', options);
+ },
+
+ willUpdate(options) {
+ pushHook(label, 'willUpdate', options);
+ },
+
+ didReceiveAttrs(options) {
+ pushHook(label, 'didReceiveAttrs', options);
+ },
+
+ willRender() {
+ pushHook(label, 'willRender');
+ },
+
+ didRender() {
+ pushHook(label, 'didRender');
+ },
+
+ didInsertElement() {
+ pushHook(label, 'didInsertElement');
+ },
+
+ didUpdate(options) {
+ pushHook(label, 'didUpdate', options);
+ }
+ });
+ }
- function component(label) {
- return Component.extend({
- init() {
- this.label = label;
- components[label] = this;
- this._super.apply(this, arguments);
- },
+ registry.register('component:the-top', component('top'));
+ registry.register('component:the-middle', component('middle'));
+ registry.register('component:the-bottom', component('bottom'));
- didInitAttrs(options) {
- pushHook(label, 'didInitAttrs', options);
- },
+ registry.register('template:components/the-top', compile(`Top: ${invoke('the-middle', { twitterTop: 'attrs.twitter' })}`));
+ registry.register('template:components/the-middle', compile(`Middle: ${invoke('the-bottom', { twitterMiddle: 'attrs.twitterTop' })}`));
+ registry.register('template:components/the-bottom', compile('Bottom: {{attrs.twitterMiddle}}'));
- didUpdateAttrs(options) {
- pushHook(label, 'didUpdateAttrs', options);
- },
+ view = EmberView.extend({
+ template: compile(invoke('the-top', { twitter: 'view.twitter' })),
+ twitter: '@tomdale',
+ container: container
+ }).create();
- willUpdate(options) {
- pushHook(label, 'willUpdate', options);
- },
+ runAppend(view);
- didReceiveAttrs(options) {
- pushHook(label, 'didReceiveAttrs', options);
- },
+ ok(component, 'The component was inserted');
+ equal(jQuery('#qunit-fixture').text(), 'Top: Middle: Bottom: @tomdale');
- willRender() {
- pushHook(label, 'willRender');
- },
+ let topAttrs = { twitter: '@tomdale' };
+ let middleAttrs = { twitterTop: '@tomdale' };
+ let bottomAttrs = { twitterMiddle: '@tomdale' };
- didRender() {
- pushHook(label, 'didRender');
- },
+ deepEqual(hooks, [
+ hook('top', 'didInitAttrs', { attrs: topAttrs }), hook('top', 'didReceiveAttrs', { newAttrs: topAttrs }), hook('top', 'willRender'),
+ hook('middle', 'didInitAttrs', { attrs: middleAttrs }), hook('middle', 'didReceiveAttrs', { newAttrs: middleAttrs }), hook('middle', 'willRender'),
+ hook('bottom', 'didInitAttrs', { attrs: bottomAttrs }), hook('bottom', 'didReceiveAttrs', { newAttrs: bottomAttrs }), hook('bottom', 'willRender'),
+ hook('bottom', 'didInsertElement'), hook('bottom', 'didRender'),
+ hook('middle', 'didInsertElement'), hook('middle', 'didRender'),
+ hook('top', 'didInsertElement'), hook('top', 'didRender')
+ ]);
- didInsertElement() {
- pushHook(label, 'didInsertElement');
- },
+ hooks = [];
- didUpdate(options) {
- pushHook(label, 'didUpdate', options);
- }
+ run(function() {
+ view.set('twitter', '@hipstertomdale');
});
- }
-
- registry.register('component:the-top', component('top'));
- registry.register('component:the-middle', component('middle'));
- registry.register('component:the-bottom', component('bottom'));
-
- registry.register('template:components/the-top', compile('Top: {{the-middle twitterTop=(readonly attrs.twitter)}}'));
- registry.register('template:components/the-middle', compile('Middle: {{the-bottom twitterMiddle=(readonly attrs.twitterTop)}}'));
- registry.register('template:components/the-bottom', compile('Bottom: {{attrs.twitterMiddle}}'));
-
- view = EmberView.extend({
- template: compile('{{the-top twitter=(readonly view.twitter)}}'),
- twitter: '@tomdale',
- container: container
- }).create();
- runAppend(view);
+ // Because the `twitter` attr is used by the all of the components,
+ // the lifecycle hooks are invoked for all components.
- ok(component, 'The component was inserted');
- equal(jQuery('#qunit-fixture').text(), 'Top: Middle: Bottom: @tomdale');
- let topAttrs = { twitter: '@tomdale' };
- let middleAttrs = { twitterTop: '@tomdale' };
- let bottomAttrs = { twitterMiddle: '@tomdale' };
+ topAttrs = { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } };
+ middleAttrs = { oldAttrs: { twitterTop: '@tomdale' }, newAttrs: { twitterTop: '@hipstertomdale' } };
+ bottomAttrs = { oldAttrs: { twitterMiddle: '@tomdale' }, newAttrs: { twitterMiddle: '@hipstertomdale' } };
- deepEqual(hooks, [
- hook('top', 'didInitAttrs', { attrs: topAttrs }), hook('top', 'didReceiveAttrs', { newAttrs: topAttrs }), hook('top', 'willRender'),
- hook('middle', 'didInitAttrs', { attrs: middleAttrs }), hook('middle', 'didReceiveAttrs', { newAttrs: middleAttrs }), hook('middle', 'willRender'),
- hook('bottom', 'didInitAttrs', { attrs: bottomAttrs }), hook('bottom', 'didReceiveAttrs', { newAttrs: bottomAttrs }), hook('bottom', 'willRender'),
- hook('bottom', 'didInsertElement'), hook('bottom', 'didRender'),
- hook('middle', 'didInsertElement'), hook('middle', 'didRender'),
- hook('top', 'didInsertElement'), hook('top', 'didRender')
- ]);
+ deepEqual(hooks, [
+ hook('top', 'didUpdateAttrs', topAttrs), hook('top', 'didReceiveAttrs', topAttrs),
+ hook('top', 'willUpdate'), hook('top', 'willRender'),
- hooks = [];
+ hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
+ hook('middle', 'willUpdate'), hook('middle', 'willRender'),
- run(function() {
- view.set('twitter', '@hipstertomdale');
- });
-
- // Because the `twitter` attr is used by the all of the components,
- // the lifecycle hooks are invoked for all components.
+ hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
+ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
+ hook('middle', 'didUpdate'), hook('middle', 'didRender'),
+ hook('top', 'didUpdate'), hook('top', 'didRender')
+ ]);
- topAttrs = { oldAttrs: { twitter: '@tomdale' }, newAttrs: { twitter: '@hipstertomdale' } };
- middleAttrs = { oldAttrs: { twitterTop: '@tomdale' }, newAttrs: { twitterTop: '@hipstertomdale' } };
- bottomAttrs = { oldAttrs: { twitterMiddle: '@tomdale' }, newAttrs: { twitterMiddle: '@hipstertomdale' } };
+ hooks = [];
- deepEqual(hooks, [
- hook('top', 'didUpdateAttrs', topAttrs), hook('top', 'didReceiveAttrs', topAttrs),
- hook('top', 'willUpdate'), hook('top', 'willRender'),
+ // In this case, because the attrs are passed down, all child components are invoked.
- hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ run(function() {
+ view.rerender();
+ });
- hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
- hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
+ topAttrs = { oldAttrs: { twitter: '@hipstertomdale' }, newAttrs: { twitter: '@hipstertomdale' } };
+ middleAttrs = { oldAttrs: { twitterTop: '@hipstertomdale' }, newAttrs: { twitterTop: '@hipstertomdale' } };
+ bottomAttrs = { oldAttrs: { twitterMiddle: '@hipstertomdale' }, newAttrs: { twitterMiddle: '@hipstertomdale' } };
- hook('middle', 'didUpdate'), hook('middle', 'didRender'),
- hook('top', 'didUpdate'), hook('top', 'didRender')
- ]);
+ deepEqual(hooks, [
+ hook('top', 'didUpdateAttrs', topAttrs), hook('top', 'didReceiveAttrs', topAttrs),
+ hook('top', 'willUpdate'), hook('top', 'willRender'),
- hooks = [];
+ hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
+ hook('middle', 'willUpdate'), hook('middle', 'willRender'),
- // In this case, because the attrs are passed down, all child components are invoked.
+ hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
+ hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
- run(function() {
- view.rerender();
+ hook('middle', 'didUpdate'), hook('middle', 'didRender'),
+ hook('top', 'didUpdate'), hook('top', 'didRender')
+ ]);
});
- topAttrs = { oldAttrs: { twitter: '@hipstertomdale' }, newAttrs: { twitter: '@hipstertomdale' } };
- middleAttrs = { oldAttrs: { twitterTop: '@hipstertomdale' }, newAttrs: { twitterTop: '@hipstertomdale' } };
- bottomAttrs = { oldAttrs: { twitterMiddle: '@hipstertomdale' }, newAttrs: { twitterMiddle: '@hipstertomdale' } };
-
- deepEqual(hooks, [
- hook('top', 'didUpdateAttrs', topAttrs), hook('top', 'didReceiveAttrs', topAttrs),
- hook('top', 'willUpdate'), hook('top', 'willRender'),
-
- hook('middle', 'didUpdateAttrs', middleAttrs), hook('middle', 'didReceiveAttrs', middleAttrs),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
-
- hook('bottom', 'didUpdateAttrs', bottomAttrs), hook('bottom', 'didReceiveAttrs', bottomAttrs),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
- hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
+ QUnit.test('changing a component\'s displayed properties inside didInsertElement() is deprecated', function(assert) {
+ let component = style.class.extend({
+ layout: compile('<div>{{debugger}}{{handle}}</div>'),
+ handle: '@wycats',
+ container: container,
- hook('middle', 'didUpdate'), hook('middle', 'didRender'),
- hook('top', 'didUpdate'), hook('top', 'didRender')
- ]);
-});
-
-QUnit.test('changing a component\'s displayed properties inside didInsertElement() is deprecated', function(assert) {
- let component = Component.extend({
- layout: compile('{{handle}}'),
- handle: '@wycats',
- container: container,
-
- didInsertElement() {
- this.set('handle', '@tomdale');
- }
- }).create();
+ didInsertElement() {
+ this.set('handle', '@tomdale');
+ }
+ }).create();
- expectDeprecation(() => {
- runAppend(component);
- }, /modified inside the didInsertElement hook/);
+ expectDeprecation(() => {
+ runAppend(component);
+ }, /modified inside the didInsertElement hook/);
- assert.strictEqual(component.$().text(), '@tomdale');
+ assert.strictEqual(component.$().text(), '@tomdale');
- run(() => {
- component.destroy();
+ run(() => {
+ component.destroy();
+ });
});
});
| true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/main.js | @@ -67,7 +67,7 @@ if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
Ember.View.cloneStates = cloneStates;
Ember.View._Renderer = Renderer;
Ember.ContainerView = DeprecatedContainerView;
- Ember.CollectionView = DeprecatedCollectionView;
+ Ember.CollectionView = CollectionView;
}
Ember._Renderer = Renderer; | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/mixins/legacy_child_views_support.js | @@ -0,0 +1,20 @@
+import { Mixin } from 'ember-metal/mixin';
+import { get } from 'ember-metal/property_get';
+import { set } from 'ember-metal/property_set';
+
+export default Mixin.create({
+ linkChild(instance) {
+ instance.container = this.container;
+ if (get(instance, 'parentView') !== this) {
+ // linkChild should be idempotent
+ set(instance, 'parentView', this);
+ instance.trigger('parentViewDidChange');
+ }
+ instance.ownerView = this.ownerView;
+ },
+
+ unlinkChild(instance) {
+ set(instance, 'parentView', null);
+ instance.trigger('parentViewDidChange');
+ }
+}); | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/mixins/legacy_view_support.js | @@ -3,7 +3,7 @@
@submodule ember-views
*/
import Ember from 'ember-metal/core';
-import { Mixin } from 'ember-metal/mixin';
+import { Mixin, observer } from 'ember-metal/mixin';
import { get } from 'ember-metal/property_get';
/**
@@ -100,7 +100,19 @@ var LegacyViewSupport = Mixin.create({
if (view instanceof klass) { return view; }
view = get(view, 'parentView');
}
- }
+ },
+
+ /**
+ If a value that affects template rendering changes, the view should be
+ re-rendered to reflect the new value.
+
+ @method _contextDidChange
+ @private
+ @private
+ */
+ _contextDidChange: observer('context', function() {
+ this.rerender();
+ })
});
export default LegacyViewSupport; | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/mixins/view_child_views_support.js | @@ -125,16 +125,11 @@ export default Mixin.create({
linkChild(instance) {
instance.container = this.container;
- if (get(instance, 'parentView') !== this) {
- // linkChild should be idempotentj
- set(instance, 'parentView', this);
- instance.trigger('parentViewDidChange');
- }
+ instance.parentView = this;
instance.ownerView = this.ownerView;
},
unlinkChild(instance) {
- set(instance, 'parentView', null);
- instance.trigger('parentViewDidChange');
+ instance.parentView = null;
}
}); | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/mixins/view_support.js | @@ -0,0 +1,770 @@
+import Ember from 'ember-metal/core';
+import EmberError from 'ember-metal/error';
+import { get } from 'ember-metal/property_get';
+import run from 'ember-metal/run_loop';
+import { addObserver, removeObserver } from 'ember-metal/observer';
+import { guidFor } from 'ember-metal/utils';
+import { computed } from 'ember-metal/computed';
+import { Mixin } from 'ember-metal/mixin';
+
+import jQuery from 'ember-views/system/jquery';
+
+function K() { return this; }
+
+export default Mixin.create({
+ concatenatedProperties: ['attributeBindings'],
+
+ /**
+ @property isView
+ @type Boolean
+ @default true
+ @static
+ @private
+ */
+ isView: true,
+
+ // ..........................................................
+ // TEMPLATE SUPPORT
+ //
+
+ /**
+ The name of the template to lookup if no template is provided.
+
+ By default `Ember.View` will lookup a template with this name in
+ `Ember.TEMPLATES` (a shared global object).
+
+ @property templateName
+ @type String
+ @default null
+ @private
+ */
+ templateName: null,
+
+ /**
+ The name of the layout to lookup if no layout is provided.
+
+ By default `Ember.View` will lookup a template with this name in
+ `Ember.TEMPLATES` (a shared global object).
+
+ @property layoutName
+ @type String
+ @default null
+ @private
+ */
+ layoutName: null,
+
+ /**
+ The template used to render the view. This should be a function that
+ accepts an optional context parameter and returns a string of HTML that
+ will be inserted into the DOM relative to its parent view.
+
+ In general, you should set the `templateName` property instead of setting
+ the template yourself.
+
+ @property template
+ @type Function
+ @private
+ */
+ template: computed('templateName', {
+ get() {
+ var templateName = get(this, 'templateName');
+ var template = this.templateForName(templateName, 'template');
+ Ember.assert('You specified the templateName ' + templateName + ' for ' + this + ', but it did not exist.', !templateName || !!template);
+ return template || get(this, 'defaultTemplate');
+ },
+ set(key, value) {
+ if (value !== undefined) { return value; }
+ return get(this, key);
+ }
+ }),
+
+ /**
+ A view may contain a layout. A layout is a regular template but
+ supersedes the `template` property during rendering. It is the
+ responsibility of the layout template to retrieve the `template`
+ property from the view (or alternatively, call `Handlebars.helpers.yield`,
+ `{{yield}}`) to render it in the correct location.
+
+ This is useful for a view that has a shared wrapper, but which delegates
+ the rendering of the contents of the wrapper to the `template` property
+ on a subclass.
+
+ @property layout
+ @type Function
+ @private
+ */
+ layout: computed('layoutName', {
+ get(key) {
+ var layoutName = get(this, 'layoutName');
+ var layout = this.templateForName(layoutName, 'layout');
+
+ Ember.assert('You specified the layoutName ' + layoutName + ' for ' + this + ', but it did not exist.', !layoutName || !!layout);
+
+ return layout || get(this, 'defaultLayout');
+ },
+
+ set(key, value) {
+ return value;
+ }
+ }),
+
+ templateForName(name, type) {
+ if (!name) { return; }
+ Ember.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1);
+
+ if (!this.container) {
+ throw new EmberError('Container was not found when looking up a views template. ' +
+ 'This is most likely due to manually instantiating an Ember.View. ' +
+ 'See: http://git.io/EKPpnA');
+ }
+
+ return this.container.lookup('template:' + name);
+ },
+
+ /**
+ Return the nearest ancestor that is an instance of the provided
+ class or mixin.
+
+ @method nearestOfType
+ @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself),
+ or an instance of Ember.Mixin.
+ @return Ember.View
+ @private
+ */
+ nearestOfType(klass) {
+ var view = get(this, 'parentView');
+ var isOfType = klass instanceof Mixin ?
+ function(view) { return klass.detect(view); } :
+ function(view) { return klass.detect(view.constructor); };
+
+ while (view) {
+ if (isOfType(view)) { return view; }
+ view = get(view, 'parentView');
+ }
+ },
+
+ /**
+ Return the nearest ancestor that has a given property.
+
+ @method nearestWithProperty
+ @param {String} property A property name
+ @return Ember.View
+ @private
+ */
+ nearestWithProperty(property) {
+ var view = get(this, 'parentView');
+
+ while (view) {
+ if (property in view) { return view; }
+ view = get(view, 'parentView');
+ }
+ },
+
+ /**
+ Renders the view again. This will work regardless of whether the
+ view is already in the DOM or not. If the view is in the DOM, the
+ rendering process will be deferred to give bindings a chance
+ to synchronize.
+
+ If children were added during the rendering process using `appendChild`,
+ `rerender` will remove them, because they will be added again
+ if needed by the next `render`.
+
+ In general, if the display of your view changes, you should modify
+ the DOM element directly instead of manually calling `rerender`, which can
+ be slow.
+
+ @method rerender
+ @public
+ */
+ rerender() {
+ return this.currentState.rerender(this);
+ },
+
+ // ..........................................................
+ // ELEMENT SUPPORT
+ //
+
+ /**
+ Returns the current DOM element for the view.
+
+ @property element
+ @type DOMElement
+ @public
+ */
+ element: null,
+
+ /**
+ Returns a jQuery object for this view's element. If you pass in a selector
+ string, this method will return a jQuery object, using the current element
+ as its buffer.
+
+ For example, calling `view.$('li')` will return a jQuery object containing
+ all of the `li` elements inside the DOM element of this view.
+
+ @method $
+ @param {String} [selector] a jQuery-compatible selector string
+ @return {jQuery} the jQuery object for the DOM node
+ @public
+ */
+ $(sel) {
+ Ember.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== '');
+ return this.currentState.$(this, sel);
+ },
+
+ forEachChildView(callback) {
+ var childViews = this.childViews;
+
+ if (!childViews) { return this; }
+
+ var len = childViews.length;
+ var view, idx;
+
+ for (idx = 0; idx < len; idx++) {
+ view = childViews[idx];
+ callback(view);
+ }
+
+ return this;
+ },
+
+ /**
+ Appends the view's element to the specified parent element.
+
+ If the view does not have an HTML representation yet, `createElement()`
+ will be called automatically.
+
+ Note that this method just schedules the view to be appended; the DOM
+ element will not be appended to the given element until all bindings have
+ finished synchronizing.
+
+ This is not typically a function that you will need to call directly when
+ building your application. You might consider using `Ember.ContainerView`
+ instead. If you do need to use `appendTo`, be sure that the target element
+ you are providing is associated with an `Ember.Application` and does not
+ have an ancestor element that is associated with an Ember view.
+
+ @method appendTo
+ @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object
+ @return {Ember.View} receiver
+ @private
+ */
+ appendTo(selector) {
+ var target = jQuery(selector);
+
+ Ember.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target.length > 0);
+ Ember.assert('You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
+
+ this.renderer.appendTo(this, target[0]);
+
+ return this;
+ },
+
+ /**
+ @private
+
+ Creates a new DOM element, renders the view into it, then returns the
+ element.
+
+ By default, the element created and rendered into will be a `BODY` element,
+ since this is the default context that views are rendered into when being
+ inserted directly into the DOM.
+
+ ```js
+ var element = view.renderToElement();
+ element.tagName; // => "BODY"
+ ```
+
+ You can override the kind of element rendered into and returned by
+ specifying an optional tag name as the first argument.
+
+ ```js
+ var element = view.renderToElement('table');
+ element.tagName; // => "TABLE"
+ ```
+
+ This method is useful if you want to render the view into an element that
+ is not in the document's body. Instead, a new `body` element, detached from
+ the DOM is returned. FastBoot uses this to serialize the rendered view into
+ a string for transmission over the network.
+
+ ```js
+ app.visit('/').then(function(instance) {
+ var element;
+ Ember.run(function() {
+ element = renderToElement(instance);
+ });
+
+ res.send(serialize(element));
+ });
+ ```
+
+ @method renderToElement
+ @param {String} tagName The tag of the element to create and render into. Defaults to "body".
+ @return {HTMLBodyElement} element
+ @private
+ */
+ renderToElement(tagName) {
+ tagName = tagName || 'body';
+
+ var element = this.renderer._dom.createElement(tagName);
+
+ this.renderer.appendTo(this, element);
+ return element;
+ },
+
+ /**
+ Replaces the content of the specified parent element with this view's
+ element. If the view does not have an HTML representation yet,
+ the element will be generated automatically.
+
+ Note that this method just schedules the view to be appended; the DOM
+ element will not be appended to the given element until all bindings have
+ finished synchronizing
+
+ @method replaceIn
+ @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object
+ @return {Ember.View} received
+ @private
+ */
+ replaceIn(selector) {
+ var target = jQuery(selector);
+
+ Ember.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0);
+ Ember.assert('You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
+
+ this.renderer.replaceIn(this, target[0]);
+
+ return this;
+ },
+
+ /**
+ Appends the view's element to the document body. If the view does
+ not have an HTML representation yet
+ the element will be generated automatically.
+
+ If your application uses the `rootElement` property, you must append
+ the view within that element. Rendering views outside of the `rootElement`
+ is not supported.
+
+ Note that this method just schedules the view to be appended; the DOM
+ element will not be appended to the document body until all bindings have
+ finished synchronizing.
+
+ @method append
+ @return {Ember.View} receiver
+ @private
+ */
+ append() {
+ return this.appendTo(document.body);
+ },
+
+ /**
+ Removes the view's element from the element to which it is attached.
+
+ @method remove
+ @return {Ember.View} receiver
+ @private
+ */
+ remove() {
+ // What we should really do here is wait until the end of the run loop
+ // to determine if the element has been re-appended to a different
+ // element.
+ // In the interim, we will just re-render if that happens. It is more
+ // important than elements get garbage collected.
+ if (!this.removedFromDOM) { this.destroyElement(); }
+
+ // Set flag to avoid future renders
+ this._willInsert = false;
+ },
+
+ /**
+ The HTML `id` of the view's element in the DOM. You can provide this
+ value yourself but it must be unique (just as in HTML):
+
+ ```handlebars
+ {{my-component elementId="a-really-cool-id"}}
+ ```
+
+ If not manually set a default value will be provided by the framework.
+
+ Once rendered an element's `elementId` is considered immutable and you
+ should never change it. If you need to compute a dynamic value for the
+ `elementId`, you should do this when the component or element is being
+ instantiated:
+
+ ```javascript
+ export default Ember.Component.extend({
+ setElementId: Ember.on('init', function() {
+ var index = this.get('index');
+ this.set('elementId', 'component-id' + index);
+ })
+ });
+ ```
+
+ @property elementId
+ @type String
+ @public
+ */
+ elementId: null,
+
+ /**
+ Attempts to discover the element in the parent element. The default
+ implementation looks for an element with an ID of `elementId` (or the
+ view's guid if `elementId` is null). You can override this method to
+ provide your own form of lookup. For example, if you want to discover your
+ element using a CSS class name instead of an ID.
+
+ @method findElementInParentElement
+ @param {DOMElement} parentElement The parent's DOM element
+ @return {DOMElement} The discovered element
+ @private
+ */
+ findElementInParentElement(parentElem) {
+ var id = '#' + this.elementId;
+ return jQuery(id)[0] || jQuery(id, parentElem)[0];
+ },
+
+ /**
+ Creates a DOM representation of the view and all of its child views by
+ recursively calling the `render()` method. Once the element is created,
+ it sets the `element` property of the view to the rendered element.
+
+ After the element has been inserted into the DOM, `didInsertElement` will
+ be called on this view and all of its child views.
+
+ @method createElement
+ @return {Ember.View} receiver
+ @private
+ */
+ createElement() {
+ if (this.element) { return this; }
+
+ this.renderer.createElement(this);
+
+ return this;
+ },
+
+ /**
+ Called when a view is going to insert an element into the DOM.
+
+ @event willInsertElement
+ @public
+ */
+ willInsertElement: K,
+
+ /**
+ Called when the element of the view has been inserted into the DOM
+ or after the view was re-rendered. Override this function to do any
+ set up that requires an element in the document body.
+
+ When a view has children, didInsertElement will be called on the
+ child view(s) first, bubbling upwards through the hierarchy.
+
+ @event didInsertElement
+ @public
+ */
+ didInsertElement: K,
+
+ /**
+ Called when the view is about to rerender, but before anything has
+ been torn down. This is a good opportunity to tear down any manual
+ observers you have installed based on the DOM state
+
+ @event willClearRender
+ @public
+ */
+ willClearRender: K,
+
+ /**
+ Destroys any existing element along with the element for any child views
+ as well. If the view does not currently have a element, then this method
+ will do nothing.
+
+ If you implement `willDestroyElement()` on your view, then this method will
+ be invoked on your view before your element is destroyed to give you a
+ chance to clean up any event handlers, etc.
+
+ If you write a `willDestroyElement()` handler, you can assume that your
+ `didInsertElement()` handler was called earlier for the same element.
+
+ You should not call or override this method yourself, but you may
+ want to implement the above callbacks.
+
+ @method destroyElement
+ @return {Ember.View} receiver
+ @private
+ */
+ destroyElement() {
+ return this.currentState.destroyElement(this);
+ },
+
+ /**
+ Called when the element of the view is going to be destroyed. Override
+ this function to do any teardown that requires an element, like removing
+ event listeners.
+
+ Please note: any property changes made during this event will have no
+ effect on object observers.
+
+ @event willDestroyElement
+ @public
+ */
+ willDestroyElement: K,
+
+ /**
+ Called when the parentView property has changed.
+
+ @event parentViewDidChange
+ @private
+ */
+ parentViewDidChange: K,
+
+ // ..........................................................
+ // STANDARD RENDER PROPERTIES
+ //
+
+ /**
+ Tag name for the view's outer element. The tag name is only used when an
+ element is first created. If you change the `tagName` for an element, you
+ must destroy and recreate the view element.
+
+ By default, the render buffer will use a `<div>` tag for views.
+
+ @property tagName
+ @type String
+ @default null
+ @public
+ */
+
+ // We leave this null by default so we can tell the difference between
+ // the default case and a user-specified tag.
+ tagName: null,
+
+ /*
+ Used to specify a default tagName that can be overridden when extending
+ or invoking from a template.
+
+ @property _defaultTagName
+ @private
+ */
+
+ /**
+ Normally, Ember's component model is "write-only". The component takes a
+ bunch of attributes that it got passed in, and uses them to render its
+ template.
+
+ One nice thing about this model is that if you try to set a value to the
+ same thing as last time, Ember (through HTMLBars) will avoid doing any
+ work on the DOM.
+
+ This is not just a performance optimization. If an attribute has not
+ changed, it is important not to clobber the element's "hidden state".
+ For example, if you set an input's `value` to the same value as before,
+ it will clobber selection state and cursor position. In other words,
+ setting an attribute is not **always** idempotent.
+
+ This method provides a way to read an element's attribute and also
+ update the last value Ember knows about at the same time. This makes
+ setting an attribute idempotent.
+
+ In particular, what this means is that if you get an `<input>` element's
+ `value` attribute and then re-render the template with the same value,
+ it will avoid clobbering the cursor and selection position.
+
+ Since most attribute sets are idempotent in the browser, you typically
+ can get away with reading attributes using jQuery, but the most reliable
+ way to do so is through this method.
+
+ @method readDOMAttr
+ @param {String} name the name of the attribute
+ @return String
+ @public
+ */
+ readDOMAttr(name) {
+ let attr = this._renderNode.childNodes.filter(node => node.attrName === name)[0];
+ if (!attr) { return null; }
+ return attr.getContent();
+ },
+
+ // .......................................................
+ // CORE DISPLAY METHODS
+ //
+
+ /**
+ Setup a view, but do not finish waking it up.
+
+ * configure `childViews`
+ * register the view with the global views hash, which is used for event
+ dispatch
+
+ @method init
+ @private
+ */
+ init() {
+ if (!this.elementId) {
+ this.elementId = guidFor(this);
+ }
+
+ this.scheduledRevalidation = false;
+
+ this._super(...arguments);
+ this.renderer.componentInitAttrs(this, this.attrs || {});
+ },
+
+ __defineNonEnumerable(property) {
+ this[property.name] = property.descriptor.value;
+ },
+
+ revalidate() {
+ this.renderer.revalidateTopLevelView(this);
+ this.scheduledRevalidation = false;
+ },
+
+ scheduleRevalidate(node, label, manualRerender) {
+ if (node && !this._dispatching && node.guid in this.env.renderedNodes) {
+ if (manualRerender) {
+ Ember.deprecate(`You manually rerendered ${label} (a parent component) from a child component during the rendering process. This rarely worked in Ember 1.x and will be removed in Ember 2.0`,
+ false,
+ { id: 'ember-views.manual-parent-rerender', until: '3.0.0' });
+ } else {
+ Ember.deprecate(`You modified ${label} twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0`,
+ false,
+ { id: 'ember-views.render-double-modify', until: '3.0.0' });
+ }
+ run.scheduleOnce('render', this, this.revalidate);
+ return;
+ }
+
+ Ember.deprecate(`A property of ${this} was modified inside the ${this._dispatching} hook. You should never change properties on components, services or models during ${this._dispatching} because it causes significant performance degradation.`,
+ !this._dispatching,
+ { id: 'ember-views.dispatching-modify-property', until: '3.0.0' });
+
+ if (!this.scheduledRevalidation || this._dispatching) {
+ this.scheduledRevalidation = true;
+ run.scheduleOnce('render', this, this.revalidate);
+ }
+ },
+
+ templateRenderer: null,
+
+ /**
+ Removes the view from its `parentView`, if one is found. Otherwise
+ does nothing.
+
+ @method removeFromParent
+ @return {Ember.View} receiver
+ @private
+ */
+ removeFromParent() {
+ var parent = this.parentView;
+
+ // Remove DOM element from parent
+ this.remove();
+
+ if (parent) { parent.removeChild(this); }
+ return this;
+ },
+
+ /**
+ You must call `destroy` on a view to destroy the view (and all of its
+ child views). This will remove the view from any parent node, then make
+ sure that the DOM element managed by the view can be released by the
+ memory manager.
+
+ @method destroy
+ @private
+ */
+ destroy() {
+ // get parentView before calling super because it'll be destroyed
+ var parentView = this.parentView;
+ var viewName = this.viewName;
+
+ if (!this._super(...arguments)) { return; }
+
+ // remove from non-virtual parent view if viewName was specified
+ if (viewName && parentView) {
+ parentView.set(viewName, null);
+ }
+
+ // Destroy HTMLbars template
+ if (this.lastResult) {
+ this.lastResult.destroy();
+ }
+
+ return this;
+ },
+
+ // .......................................................
+ // EVENT HANDLING
+ //
+
+ /**
+ Handle events from `Ember.EventDispatcher`
+
+ @method handleEvent
+ @param eventName {String}
+ @param evt {Event}
+ @private
+ */
+ handleEvent(eventName, evt) {
+ return this.currentState.handleEvent(this, eventName, evt);
+ },
+
+ /**
+ Registers the view in the view registry, keyed on the view's `elementId`.
+ This is used by the EventDispatcher to locate the view in response to
+ events.
+
+ This method should only be called once the view has been inserted into the
+ DOM.
+
+ @method _register
+ @private
+ */
+ _register() {
+ Ember.assert('Attempted to register a view with an id already in use: ' + this.elementId, !this._viewRegistry[this.elementId]);
+ this._viewRegistry[this.elementId] = this;
+ },
+
+ /**
+ Removes the view from the view registry. This should be called when the
+ view is removed from DOM.
+
+ @method _unregister
+ @private
+ */
+ _unregister() {
+ delete this._viewRegistry[this.elementId];
+ },
+
+ registerObserver(root, path, target, observer) {
+ if (!observer && 'function' === typeof target) {
+ observer = target;
+ target = null;
+ }
+
+ if (!root || typeof root !== 'object') {
+ return;
+ }
+
+ var scheduledObserver = this._wrapAsScheduled(observer);
+
+ addObserver(root, path, target, scheduledObserver);
+
+ this.one('willClearRender', function() {
+ removeObserver(root, path, target, scheduledObserver);
+ });
+ },
+
+ _wrapAsScheduled(fn) {
+ var view = this;
+ var stateCheckedFn = function() {
+ view.currentState.invokeObserver(this, fn);
+ };
+ var scheduledFn = function() {
+ run.scheduleOnce('render', this, stateCheckedFn);
+ };
+ return scheduledFn;
+ }
+}); | true |
Other | emberjs | ember.js | a6856fdaf25afa4fbdf971a54084874eeece896b.json | Create GlimmerComponent subclass | packages/ember-views/lib/views/view.js | @@ -4,23 +4,12 @@
// Ember.ENV
import Ember from 'ember-metal/core';
-import EmberError from 'ember-metal/error';
-import { get } from 'ember-metal/property_get';
-import run from 'ember-metal/run_loop';
-import { addObserver, removeObserver } from 'ember-metal/observer';
-import { guidFor } from 'ember-metal/utils';
-import { computed } from 'ember-metal/computed';
-import {
- Mixin,
- observer
-} from 'ember-metal/mixin';
-
-import jQuery from 'ember-views/system/jquery';
import 'ember-views/system/ext'; // for the side effect of extending Ember.run.queues
import CoreView from 'ember-views/views/core_view';
import ViewContextSupport from 'ember-views/mixins/view_context_support';
import ViewChildViewsSupport from 'ember-views/mixins/view_child_views_support';
+import ViewLegacyChildViewsSupport from 'ember-views/mixins/legacy_child_views_support';
import {
childViewsProperty
} from 'ember-views/mixins/view_child_views_support';
@@ -32,8 +21,7 @@ import InstrumentationSupport from 'ember-views/mixins/instrumentation_support';
import AriaRoleSupport from 'ember-views/mixins/aria_role_support';
import VisibilitySupport from 'ember-views/mixins/visibility_support';
import CompatAttrsProxy from 'ember-views/compat/attrs-proxy';
-
-function K() { return this; }
+import ViewMixin from 'ember-views/mixins/view_support';
/**
@module ember
@@ -673,802 +661,39 @@ Ember.TEMPLATES = {};
var View = CoreView.extend(
ViewContextSupport,
ViewChildViewsSupport,
+ ViewLegacyChildViewsSupport,
ViewStateSupport,
TemplateRenderingSupport,
ClassNamesSupport,
LegacyViewSupport,
InstrumentationSupport,
VisibilitySupport,
CompatAttrsProxy,
- AriaRoleSupport, {
- concatenatedProperties: ['attributeBindings'],
-
- /**
- @property isView
- @type Boolean
- @default true
- @static
- @private
- */
- isView: true,
-
- // ..........................................................
- // TEMPLATE SUPPORT
- //
-
- /**
- The name of the template to lookup if no template is provided.
-
- By default `Ember.View` will lookup a template with this name in
- `Ember.TEMPLATES` (a shared global object).
-
- @property templateName
- @type String
- @default null
- @private
- */
- templateName: null,
-
- /**
- The name of the layout to lookup if no layout is provided.
-
- By default `Ember.View` will lookup a template with this name in
- `Ember.TEMPLATES` (a shared global object).
-
- @property layoutName
- @type String
- @default null
- @public
- */
- layoutName: null,
-
- /**
- The template used to render the view. This should be a function that
- accepts an optional context parameter and returns a string of HTML that
- will be inserted into the DOM relative to its parent view.
-
- In general, you should set the `templateName` property instead of setting
- the template yourself.
-
- @property template
- @type Function
- @private
- */
- template: computed('templateName', {
- get() {
- var templateName = get(this, 'templateName');
- var template = this.templateForName(templateName, 'template');
- Ember.assert('You specified the templateName ' + templateName + ' for ' + this + ', but it did not exist.', !templateName || !!template);
- return template || get(this, 'defaultTemplate');
- },
- set(key, value) {
- if (value !== undefined) { return value; }
- return get(this, key);
- }
- }),
-
- /**
- A view may contain a layout. A layout is a regular template but
- supersedes the `template` property during rendering. It is the
- responsibility of the layout template to retrieve the `template`
- property from the view (or alternatively, call `Handlebars.helpers.yield`,
- `{{yield}}`) to render it in the correct location.
-
- This is useful for a view that has a shared wrapper, but which delegates
- the rendering of the contents of the wrapper to the `template` property
- on a subclass.
-
- @property layout
- @type Function
- @public
- */
- layout: computed('layoutName', {
- get(key) {
- var layoutName = get(this, 'layoutName');
- var layout = this.templateForName(layoutName, 'layout');
-
- Ember.assert('You specified the layoutName ' + layoutName + ' for ' + this + ', but it did not exist.', !layoutName || !!layout);
-
- return layout || get(this, 'defaultLayout');
- },
-
- set(key, value) {
- return value;
- }
- }),
-
- templateForName(name, type) {
- if (!name) { return; }
- Ember.assert('templateNames are not allowed to contain periods: ' + name, name.indexOf('.') === -1);
-
- if (!this.container) {
- throw new EmberError('Container was not found when looking up a views template. ' +
- 'This is most likely due to manually instantiating an Ember.View. ' +
- 'See: http://git.io/EKPpnA');
- }
-
- return this.container.lookup('template:' + name);
- },
-
- /**
- If a value that affects template rendering changes, the view should be
- re-rendered to reflect the new value.
-
- @method _contextDidChange
- @private
- @private
- */
- _contextDidChange: observer('context', function() {
- this.rerender();
- }),
-
- /**
- Return the nearest ancestor that is an instance of the provided
- class or mixin.
-
- @method nearestOfType
- @param {Class,Mixin} klass Subclass of Ember.View (or Ember.View itself),
- or an instance of Ember.Mixin.
- @return Ember.View
- @private
- */
- nearestOfType(klass) {
- var view = get(this, 'parentView');
- var isOfType = klass instanceof Mixin ?
- function(view) { return klass.detect(view); } :
- function(view) { return klass.detect(view.constructor); };
-
- while (view) {
- if (isOfType(view)) { return view; }
- view = get(view, 'parentView');
- }
- },
-
- /**
- Return the nearest ancestor that has a given property.
-
- @method nearestWithProperty
- @param {String} property A property name
- @return Ember.View
- @private
- */
- nearestWithProperty(property) {
- var view = get(this, 'parentView');
-
- while (view) {
- if (property in view) { return view; }
- view = get(view, 'parentView');
- }
- },
-
- /**
- Renders the view again. This will work regardless of whether the
- view is already in the DOM or not. If the view is in the DOM, the
- rendering process will be deferred to give bindings a chance
- to synchronize.
-
- If children were added during the rendering process using `appendChild`,
- `rerender` will remove them, because they will be added again
- if needed by the next `render`.
-
- In general, if the display of your view changes, you should modify
- the DOM element directly instead of manually calling `rerender`, which can
- be slow.
-
- @method rerender
- @public
- */
- rerender() {
- return this.currentState.rerender(this);
- },
-
- /**
- Given a property name, returns a dasherized version of that
- property name if the property evaluates to a non-falsy value.
-
- For example, if the view has property `isUrgent` that evaluates to true,
- passing `isUrgent` to this method will return `"is-urgent"`.
-
- @method _classStringForProperty
- @param property
- @private
- */
- _classStringForProperty(parsedPath) {
- return View._classStringForValue(parsedPath.path, parsedPath.stream.value(), parsedPath.className, parsedPath.falsyClassName);
- },
-
- // ..........................................................
- // ELEMENT SUPPORT
- //
-
- /**
- Returns the current DOM element for the view.
-
- @property element
- @type DOMElement
- @public
- */
- element: null,
-
- /**
- Returns a jQuery object for this view's element. If you pass in a selector
- string, this method will return a jQuery object, using the current element
- as its buffer.
-
- For example, calling `view.$('li')` will return a jQuery object containing
- all of the `li` elements inside the DOM element of this view.
-
- @method $
- @param {String} [selector] a jQuery-compatible selector string
- @return {jQuery} the jQuery object for the DOM node
- @public
- */
- $(sel) {
- Ember.assert('You cannot access this.$() on a component with `tagName: \'\'` specified.', this.tagName !== '');
- return this.currentState.$(this, sel);
- },
-
- forEachChildView(callback) {
- var childViews = this.childViews;
-
- if (!childViews) { return this; }
-
- var len = childViews.length;
- var view, idx;
-
- for (idx = 0; idx < len; idx++) {
- view = childViews[idx];
- callback(view);
- }
-
- return this;
- },
-
- /**
- Appends the view's element to the specified parent element.
-
- If the view does not have an HTML representation yet, `createElement()`
- will be called automatically.
-
- Note that this method just schedules the view to be appended; the DOM
- element will not be appended to the given element until all bindings have
- finished synchronizing.
-
- This is not typically a function that you will need to call directly when
- building your application. You might consider using `Ember.ContainerView`
- instead. If you do need to use `appendTo`, be sure that the target element
- you are providing is associated with an `Ember.Application` and does not
- have an ancestor element that is associated with an Ember view.
-
- @method appendTo
- @param {String|DOMElement|jQuery} A selector, element, HTML string, or jQuery object
- @return {Ember.View} receiver
- @private
- */
- appendTo(selector) {
- var target = jQuery(selector);
-
- Ember.assert('You tried to append to (' + selector + ') but that isn\'t in the DOM', target.length > 0);
- Ember.assert('You cannot append to an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
-
- this.renderer.appendTo(this, target[0]);
-
- return this;
- },
-
- /**
- @private
-
- Creates a new DOM element, renders the view into it, then returns the
- element.
-
- By default, the element created and rendered into will be a `BODY` element,
- since this is the default context that views are rendered into when being
- inserted directly into the DOM.
-
- ```js
- var element = view.renderToElement();
- element.tagName; // => "BODY"
- ```
-
- You can override the kind of element rendered into and returned by
- specifying an optional tag name as the first argument.
-
- ```js
- var element = view.renderToElement('table');
- element.tagName; // => "TABLE"
- ```
-
- This method is useful if you want to render the view into an element that
- is not in the document's body. Instead, a new `body` element, detached from
- the DOM is returned. FastBoot uses this to serialize the rendered view into
- a string for transmission over the network.
-
- ```js
- app.visit('/').then(function(instance) {
- var element;
- Ember.run(function() {
- element = renderToElement(instance);
- });
-
- res.send(serialize(element));
- });
- ```
-
- @method renderToElement
- @param {String} tagName The tag of the element to create and render into. Defaults to "body".
- @return {HTMLBodyElement} element
- @private
- */
- renderToElement(tagName) {
- tagName = tagName || 'body';
-
- var element = this.renderer._dom.createElement(tagName);
-
- this.renderer.appendTo(this, element);
- return element;
- },
-
- /**
- Replaces the content of the specified parent element with this view's
- element. If the view does not have an HTML representation yet,
- the element will be generated automatically.
-
- Note that this method just schedules the view to be appended; the DOM
- element will not be appended to the given element until all bindings have
- finished synchronizing
-
- @method replaceIn
- @param {String|DOMElement|jQuery} target A selector, element, HTML string, or jQuery object
- @return {Ember.View} received
- @private
- */
- replaceIn(selector) {
- var target = jQuery(selector);
-
- Ember.assert('You tried to replace in (' + selector + ') but that isn\'t in the DOM', target.length > 0);
- Ember.assert('You cannot replace an existing Ember.View. Consider using Ember.ContainerView instead.', !target.is('.ember-view') && !target.parents().is('.ember-view'));
-
- this.renderer.replaceIn(this, target[0]);
-
- return this;
- },
-
- /**
- Appends the view's element to the document body. If the view does
- not have an HTML representation yet
- the element will be generated automatically.
-
- If your application uses the `rootElement` property, you must append
- the view within that element. Rendering views outside of the `rootElement`
- is not supported.
-
- Note that this method just schedules the view to be appended; the DOM
- element will not be appended to the document body until all bindings have
- finished synchronizing.
-
- @method append
- @return {Ember.View} receiver
- @private
- */
- append() {
- return this.appendTo(document.body);
- },
-
- /**
- Removes the view's element from the element to which it is attached.
-
- @method remove
- @return {Ember.View} receiver
- @private
- */
- remove() {
- // What we should really do here is wait until the end of the run loop
- // to determine if the element has been re-appended to a different
- // element.
- // In the interim, we will just re-render if that happens. It is more
- // important than elements get garbage collected.
- if (!this.removedFromDOM) { this.destroyElement(); }
-
- // Set flag to avoid future renders
- this._willInsert = false;
- },
-
- /**
- The HTML `id` of the view's element in the DOM. You can provide this
- value yourself but it must be unique (just as in HTML):
-
- ```handlebars
- {{my-component elementId="a-really-cool-id"}}
- ```
-
- If not manually set a default value will be provided by the framework.
-
- Once rendered an element's `elementId` is considered immutable and you
- should never change it. If you need to compute a dynamic value for the
- `elementId`, you should do this when the component or element is being
- instantiated:
-
- ```javascript
- export default Ember.Component.extend({
- setElementId: Ember.on('init', function() {
- var index = this.get('index');
- this.set('elementId', 'component-id' + index);
- })
- });
- ```
-
- @property elementId
- @type String
- @public
- */
- elementId: null,
-
- /**
- Attempts to discover the element in the parent element. The default
- implementation looks for an element with an ID of `elementId` (or the
- view's guid if `elementId` is null). You can override this method to
- provide your own form of lookup. For example, if you want to discover your
- element using a CSS class name instead of an ID.
-
- @method findElementInParentElement
- @param {DOMElement} parentElement The parent's DOM element
- @return {DOMElement} The discovered element
- @private
- */
- findElementInParentElement(parentElem) {
- var id = '#' + this.elementId;
- return jQuery(id)[0] || jQuery(id, parentElem)[0];
- },
-
- /**
- Creates a DOM representation of the view and all of its child views by
- recursively calling the `render()` method. Once the element is created,
- it sets the `element` property of the view to the rendered element.
-
- After the element has been inserted into the DOM, `didInsertElement` will
- be called on this view and all of its child views.
-
- @method createElement
- @return {Ember.View} receiver
- @private
- */
- createElement() {
- if (this.element) { return this; }
-
- this.renderer.createElement(this);
-
- return this;
- },
-
- /**
- Called when a view is going to insert an element into the DOM.
-
- @event willInsertElement
- @public
- */
- willInsertElement: K,
-
- /**
- Called when the element of the view has been inserted into the DOM
- or after the view was re-rendered. Override this function to do any
- set up that requires an element in the document body.
-
- When a view has children, didInsertElement will be called on the
- child view(s) first, bubbling upwards through the hierarchy.
-
- @event didInsertElement
- @public
- */
- didInsertElement: K,
-
- /**
- Called when the view is about to rerender, but before anything has
- been torn down. This is a good opportunity to tear down any manual
- observers you have installed based on the DOM state
-
- @event willClearRender
- @public
- */
- willClearRender: K,
-
- /**
- Destroys any existing element along with the element for any child views
- as well. If the view does not currently have a element, then this method
- will do nothing.
-
- If you implement `willDestroyElement()` on your view, then this method will
- be invoked on your view before your element is destroyed to give you a
- chance to clean up any event handlers, etc.
-
- If you write a `willDestroyElement()` handler, you can assume that your
- `didInsertElement()` handler was called earlier for the same element.
-
- You should not call or override this method yourself, but you may
- want to implement the above callbacks.
-
- @method destroyElement
- @return {Ember.View} receiver
- @private
- */
- destroyElement() {
- return this.currentState.destroyElement(this);
- },
-
- /**
- Called when the element of the view is going to be destroyed. Override
- this function to do any teardown that requires an element, like removing
- event listeners.
-
- Please note: any property changes made during this event will have no
- effect on object observers.
-
- @event willDestroyElement
- @public
- */
- willDestroyElement: K,
-
- /**
- Called when the parentView property has changed.
-
- @event parentViewDidChange
- @private
- */
- parentViewDidChange: K,
-
- // ..........................................................
- // STANDARD RENDER PROPERTIES
- //
-
- /**
- Tag name for the view's outer element. The tag name is only used when an
- element is first created. If you change the `tagName` for an element, you
- must destroy and recreate the view element.
-
- By default, the render buffer will use a `<div>` tag for views.
-
- @property tagName
- @type String
- @default null
- @public
- */
-
- // We leave this null by default so we can tell the difference between
- // the default case and a user-specified tag.
- tagName: null,
-
- /*
- Used to specify a default tagName that can be overridden when extending
- or invoking from a template.
-
- @property _defaultTagName
- @private
- */
-
- /**
- Normally, Ember's component model is "write-only". The component takes a
- bunch of attributes that it got passed in, and uses them to render its
- template.
-
- One nice thing about this model is that if you try to set a value to the
- same thing as last time, Ember (through HTMLBars) will avoid doing any
- work on the DOM.
-
- This is not just a performance optimization. If an attribute has not
- changed, it is important not to clobber the element's "hidden state".
- For example, if you set an input's `value` to the same value as before,
- it will clobber selection state and cursor position. In other words,
- setting an attribute is not **always** idempotent.
-
- This method provides a way to read an element's attribute and also
- update the last value Ember knows about at the same time. This makes
- setting an attribute idempotent.
-
- In particular, what this means is that if you get an `<input>` element's
- `value` attribute and then re-render the template with the same value,
- it will avoid clobbering the cursor and selection position.
-
- Since most attribute sets are idempotent in the browser, you typically
- can get away with reading attributes using jQuery, but the most reliable
- way to do so is through this method.
-
- @method readDOMAttr
- @param {String} name the name of the attribute
- @return String
- @public
- */
- readDOMAttr(name) {
- let attr = this._renderNode.childNodes.filter(node => node.attrName === name)[0];
- if (!attr) { return null; }
- return attr.getContent();
- },
-
- // .......................................................
- // CORE DISPLAY METHODS
- //
-
- /**
- Setup a view, but do not finish waking it up.
-
- * configure `childViews`
- * register the view with the global views hash, which is used for event
- dispatch
-
- @method init
- @private
- */
- init() {
- if (!this.elementId) {
- this.elementId = guidFor(this);
- }
-
- this.scheduledRevalidation = false;
+ AriaRoleSupport,
+ ViewMixin, {
+ init() {
+ this._super(...arguments);
- this._super(...arguments);
-
- if (!this._viewRegistry) {
- this._viewRegistry = View.views;
- }
-
- this.renderer.componentInitAttrs(this, this.attrs || {});
- },
-
- __defineNonEnumerable(property) {
- this[property.name] = property.descriptor.value;
- },
-
- revalidate() {
- this.renderer.revalidateTopLevelView(this);
- this.scheduledRevalidation = false;
- },
-
- scheduleRevalidate(node, label, manualRerender) {
- if (node && !this._dispatching && node.guid in this.env.renderedNodes) {
- if (manualRerender) {
- Ember.deprecate(`You manually rerendered ${label} (a parent component) from a child component during the rendering process. This rarely worked in Ember 1.x and will be removed in Ember 2.0`,
- false,
- { id: 'ember-views.manual-parent-rerender', until: '3.0.0' });
- } else {
- Ember.deprecate(`You modified ${label} twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0`,
- false,
- { id: 'ember-views.render-double-modify', until: '3.0.0' });
+ if (!this._viewRegistry) {
+ this._viewRegistry = View.views;
}
- run.scheduleOnce('render', this, this.revalidate);
- return;
- }
-
- Ember.deprecate(`A property of ${this} was modified inside the ${this._dispatching} hook. You should never change properties on components, services or models during ${this._dispatching} because it causes significant performance degradation.`,
- !this._dispatching,
- { id: 'ember-views.dispatching-modify-property', until: '3.0.0' });
-
- if (!this.scheduledRevalidation || this._dispatching) {
- this.scheduledRevalidation = true;
- run.scheduleOnce('render', this, this.revalidate);
- }
- },
-
- templateRenderer: null,
-
- /**
- Removes the view from its `parentView`, if one is found. Otherwise
- does nothing.
-
- @method removeFromParent
- @return {Ember.View} receiver
- @private
- */
- removeFromParent() {
- var parent = this.parentView;
-
- // Remove DOM element from parent
- this.remove();
-
- if (parent) { parent.removeChild(this); }
- return this;
- },
-
- /**
- You must call `destroy` on a view to destroy the view (and all of its
- child views). This will remove the view from any parent node, then make
- sure that the DOM element managed by the view can be released by the
- memory manager.
-
- @method destroy
- @private
- */
- destroy() {
- // get parentView before calling super because it'll be destroyed
- var parentView = this.parentView;
- var viewName = this.viewName;
-
- if (!this._super(...arguments)) { return; }
-
- // remove from non-virtual parent view if viewName was specified
- if (viewName && parentView) {
- parentView.set(viewName, null);
- }
-
- // Destroy HTMLbars template
- if (this.lastResult) {
- this.lastResult.destroy();
- }
-
- return this;
- },
-
- // .......................................................
- // EVENT HANDLING
- //
-
- /**
- Handle events from `Ember.EventDispatcher`
-
- @method handleEvent
- @param eventName {String}
- @param evt {Event}
- @private
- */
- handleEvent(eventName, evt) {
- return this.currentState.handleEvent(this, eventName, evt);
- },
-
- /**
- Registers the view in the view registry, keyed on the view's `elementId`.
- This is used by the EventDispatcher to locate the view in response to
- events.
-
- This method should only be called once the view has been inserted into the
- DOM.
-
- @method _register
- @private
- */
- _register() {
- Ember.assert('Attempted to register a view with an id already in use: ' + this.elementId, !this._viewRegistry[this.elementId]);
- this._viewRegistry[this.elementId] = this;
- },
+ },
- /**
- Removes the view from the view registry. This should be called when the
- view is removed from DOM.
+ /**
+ Given a property name, returns a dasherized version of that
+ property name if the property evaluates to a non-falsy value.
- @method _unregister
- @private
- */
- _unregister() {
- delete this._viewRegistry[this.elementId];
- },
-
- registerObserver(root, path, target, observer) {
- if (!observer && 'function' === typeof target) {
- observer = target;
- target = null;
- }
+ For example, if the view has property `isUrgent` that evaluates to true,
+ passing `isUrgent` to this method will return `"is-urgent"`.
- if (!root || typeof root !== 'object') {
- return;
+ @method _classStringForProperty
+ @param property
+ @private
+ */
+ _classStringForProperty(parsedPath) {
+ return View._classStringForValue(parsedPath.path, parsedPath.stream.value(), parsedPath.className, parsedPath.falsyClassName);
}
-
- var scheduledObserver = this._wrapAsScheduled(observer);
-
- addObserver(root, path, target, scheduledObserver);
-
- this.one('willClearRender', function() {
- removeObserver(root, path, target, scheduledObserver);
- });
- },
-
- _wrapAsScheduled(fn) {
- var view = this;
- var stateCheckedFn = function() {
- view.currentState.invokeObserver(this, fn);
- };
- var scheduledFn = function() {
- run.scheduleOnce('render', this, stateCheckedFn);
- };
- return scheduledFn;
- }
-});
+ });
// jscs:enable validateIndentation
/* | true |
Other | emberjs | ember.js | c8f6ecd52885dd4865d9cc3c105da111bd88cd37.json | Remove internal uses of beforeObservers
This refactors array_proxy, collection_view, and container_view to not
depend on beforeObservers. The motivation here is to get us closer to
the point where an app that doesn't use any beforeObservers doesn't need
to pay the performance cost of supporting them. | packages/ember-runtime/lib/system/array_proxy.js | @@ -4,10 +4,7 @@ import {
isArray
} from 'ember-runtime/utils';
import { computed } from 'ember-metal/computed';
-import {
- _beforeObserver,
- observer
-} from 'ember-metal/mixin';
+import { observer } from 'ember-metal/mixin';
import {
beginPropertyChanges,
endPropertyChanges
@@ -77,7 +74,23 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
@type Ember.Array
@private
*/
- content: null,
+ content: computed({
+ get() {
+ return this._content;
+ },
+ set(k, v) {
+ if (this._didInitArrayProxy) {
+ var oldContent = this._content;
+ var len = oldContent ? get(oldContent, 'length') : 0;
+ this.arrangedContentArrayWillChange(this, 0, len, undefined);
+ this.arrangedContentWillChange(this);
+ }
+ this._content = v;
+ return v;
+ }
+ }),
+
+
/**
The array that the proxy pretends to be. In the default `ArrayProxy`
@@ -86,7 +99,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
@property arrangedContent
@private
- */
+ */
arrangedContent: alias('content'),
/**
@@ -124,20 +137,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
get(this, 'content').replace(idx, amt, objects);
},
- /**
- Invoked when the content property is about to change. Notifies observers that the
- entire array content will change.
-
- @private
- @method _contentWillChange
- */
- _contentWillChange: _beforeObserver('content', function() {
- this._teardownContent();
- }),
-
- _teardownContent() {
- var content = get(this, 'content');
-
+ _teardownContent(content) {
if (content) {
content.removeArrayObserver(this, {
willChange: 'contentArrayWillChange',
@@ -180,6 +180,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
*/
_contentDidChange: observer('content', function() {
var content = get(this, 'content');
+ this._teardownContent(this._prevContent);
Ember.assert('Can\'t set ArrayProxy\'s content to itself', content !== this);
@@ -188,6 +189,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
_setupContent() {
var content = get(this, 'content');
+ this._prevContent = content;
if (content) {
Ember.assert(`ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ${typeof content}`, isArray(content) || content.isDestroyed);
@@ -199,17 +201,8 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
}
},
- _arrangedContentWillChange: _beforeObserver('arrangedContent', function() {
- var arrangedContent = get(this, 'arrangedContent');
- var len = arrangedContent ? get(arrangedContent, 'length') : 0;
-
- this.arrangedContentArrayWillChange(this, 0, len, undefined);
- this.arrangedContentWillChange(this);
-
- this._teardownArrangedContent(arrangedContent);
- }),
-
_arrangedContentDidChange: observer('arrangedContent', function() {
+ this._teardownArrangedContent(this._prevArrangedContent);
var arrangedContent = get(this, 'arrangedContent');
var len = arrangedContent ? get(arrangedContent, 'length') : 0;
@@ -223,6 +216,7 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
_setupArrangedContent() {
var arrangedContent = get(this, 'arrangedContent');
+ this._prevArrangedContent = arrangedContent;
if (arrangedContent) {
Ember.assert(`ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ${typeof arrangedContent}`,
@@ -375,14 +369,15 @@ var ArrayProxy = EmberObject.extend(MutableArray, {
},
init() {
+ this._didInitArrayProxy = true;
this._super(...arguments);
this._setupContent();
this._setupArrangedContent();
},
willDestroy() {
this._teardownArrangedContent();
- this._teardownContent();
+ this._teardownContent(this.get('content'));
}
});
| true |
Other | emberjs | ember.js | c8f6ecd52885dd4865d9cc3c105da111bd88cd37.json | Remove internal uses of beforeObservers
This refactors array_proxy, collection_view, and container_view to not
depend on beforeObservers. The motivation here is to get us closer to
the point where an app that doesn't use any beforeObservers doesn't need
to pay the performance cost of supporting them. | packages/ember-runtime/tests/system/array_proxy/content_change_test.js | @@ -22,13 +22,11 @@ QUnit.test('The `arrangedContentWillChange` method is invoked before `content` i
var expectedLength;
var proxy = ArrayProxy.extend({
- content: Ember.A([1, 2, 3]),
-
arrangedContentWillChange() {
equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked before array has changed');
callCount++;
}
- }).create();
+ }).create({ content: Ember.A([1, 2, 3]) });
proxy.pushObject(4);
equal(callCount, 0, 'pushing content onto the array doesn\'t trigger it');
@@ -46,13 +44,13 @@ QUnit.test('The `arrangedContentDidChange` method is invoked after `content` is
var expectedLength;
var proxy = ArrayProxy.extend({
- content: Ember.A([1, 2, 3]),
-
arrangedContentDidChange() {
equal(this.get('arrangedContent.length'), expectedLength, 'hook should be invoked after array has changed');
callCount++;
}
- }).create();
+ }).create({
+ content: Ember.A([1, 2, 3])
+ });
equal(callCount, 0, 'hook is not called after creating the object');
| true |
Other | emberjs | ember.js | c8f6ecd52885dd4865d9cc3c105da111bd88cd37.json | Remove internal uses of beforeObservers
This refactors array_proxy, collection_view, and container_view to not
depend on beforeObservers. The motivation here is to get us closer to
the point where an app that doesn't use any beforeObservers doesn't need
to pay the performance cost of supporting them. | packages/ember-views/lib/views/collection_view.js | @@ -10,10 +10,7 @@ import EmberArray from 'ember-runtime/mixins/array';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { computed } from 'ember-metal/computed';
-import {
- observer,
- _beforeObserver
-} from 'ember-metal/mixin';
+import { observer } from 'ember-metal/mixin';
import { readViewFactory } from 'ember-views/streams/utils';
import EmptyViewSupport from 'ember-views/mixins/empty_view_support';
@@ -214,21 +211,6 @@ var CollectionView = ContainerView.extend(EmptyViewSupport, {
return ret;
},
- /**
- Invoked when the content property is about to change. Notifies observers that the
- entire array content will change.
-
- @private
- @method _contentWillChange
- */
- _contentWillChange: _beforeObserver('content', function() {
- var content = this.get('content');
-
- if (content) { content.removeArrayObserver(this); }
- var len = content ? get(content, 'length') : 0;
- this.arrayWillChange(content, 0, len);
- }),
-
/**
Check to make sure that the content has changed, and if so,
update the children directly. This is always scheduled
@@ -239,14 +221,20 @@ var CollectionView = ContainerView.extend(EmptyViewSupport, {
@method _contentDidChange
*/
_contentDidChange: observer('content', function() {
+ var prevContent = this._prevContent;
+ if (prevContent) { prevContent.removeArrayObserver(this); }
+ var len = prevContent ? get(prevContent, 'length') : 0;
+ this.arrayWillChange(prevContent, 0, len);
+
var content = get(this, 'content');
if (content) {
+ this._prevContent = content;
this._assertArrayLike(content);
content.addArrayObserver(this);
}
- var len = content ? get(content, 'length') : 0;
+ len = content ? get(content, 'length') : 0;
this.arrayDidChange(content, 0, null, len);
}),
| true |
Other | emberjs | ember.js | c8f6ecd52885dd4865d9cc3c105da111bd88cd37.json | Remove internal uses of beforeObservers
This refactors array_proxy, collection_view, and container_view to not
depend on beforeObservers. The motivation here is to get us closer to
the point where an app that doesn't use any beforeObservers doesn't need
to pay the performance cost of supporting them. | packages/ember-views/lib/views/container_view.js | @@ -4,10 +4,7 @@ import View from 'ember-views/views/view';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
-import {
- observer,
- _beforeObserver
-} from 'ember-metal/mixin';
+import { observer } from 'ember-metal/mixin';
import { on } from 'ember-metal/events';
import containerViewTemplate from 'ember-htmlbars/templates/container-view';
@@ -181,7 +178,7 @@ var ContainerView = View.extend(MutableArray, {
init() {
this._super(...arguments);
-
+ this._prevCurrentView = undefined;
var userChildViews = get(this, 'childViews');
Ember.deprecate('Setting `childViews` on a Container is deprecated.',
Ember.isEmpty(userChildViews),
@@ -228,15 +225,13 @@ var ContainerView = View.extend(MutableArray, {
}
},
- _currentViewWillChange: _beforeObserver('currentView', function() {
- var currentView = get(this, 'currentView');
- if (currentView) {
- currentView.destroy();
- }
- }),
-
_currentViewDidChange: observer('currentView', function() {
+ var prevView = this._prevCurrentView;
+ if (prevView) {
+ prevView.destroy();
+ }
var currentView = get(this, 'currentView');
+ this._prevCurrentView = currentView;
if (currentView) {
Ember.assert('You tried to set a current view that already has a parent. Make sure you don\'t have multiple outlets in the same view.', !currentView.parentView);
this.pushObject(currentView); | true |
Other | emberjs | ember.js | 1e5d5850ded0dc791bb7e960d36df078a28b205a.json | remove duplicate test
Lines 15-34 in the same file already define exactly the same test.
I'm guessing it was just a forgotten copy and paste. | packages/ember-metal/tests/meta_test.js | @@ -33,27 +33,6 @@ QUnit.test('meta is not enumerable', function () {
}
});
-QUnit.test('meta is not enumerable', function () {
- var proto, obj, props, prop;
- proto = { foo: 'bar' };
- meta(proto);
- obj = Object.create(proto);
- meta(obj);
- obj.bar = 'baz';
- props = [];
- for (prop in obj) {
- props.push(prop);
- }
- deepEqual(props.sort(), ['bar', 'foo']);
- if (typeof JSON !== 'undefined' && 'stringify' in JSON) {
- try {
- JSON.stringify(obj);
- } catch (e) {
- ok(false, 'meta should not fail JSON.stringify');
- }
- }
-});
-
QUnit.test('meta.listeners basics', function(assert) {
let t = {};
let m = meta({}); | false |
Other | emberjs | ember.js | 714f0b8b7d4c95d18b561845493cc031d182eec7.json | use empty object | packages/ember-metal/lib/meta.js | @@ -5,6 +5,7 @@
import isEnabled from 'ember-metal/features';
import { protoMethods as listenerMethods } from 'ember-metal/meta_listeners';
+import EmptyObject from 'ember-metal/empty_object';
/**
@module ember-metal
@@ -84,7 +85,7 @@ function ownMap(name, Meta) {
Meta.prototype._getOrCreateOwnMap = function(key) {
let ret = this[key];
if (!ret) {
- ret = this[key] = {};
+ ret = this[key] = new EmptyObject();
}
return ret;
};
@@ -111,7 +112,7 @@ function inheritedMap(name, Meta) {
};
Meta.prototype['clear' + capitalized] = function() {
- this[key] = {};
+ this[key] = new EmptyObject();
};
}
@@ -121,7 +122,7 @@ Meta.prototype._getOrCreateInheritedMap = function(key) {
if (this.parent) {
ret = this[key] = Object.create(this.parent._getOrCreateInheritedMap(key));
} else {
- ret = this[key] = {};
+ ret = this[key] = new EmptyObject();
}
}
return ret;
@@ -147,7 +148,7 @@ function inheritedMapOfMaps(name, Meta) {
let outerMap = this._getOrCreateInheritedMap(key);
let innerMap = outerMap[subkey];
if (!innerMap) {
- innerMap = outerMap[subkey] = {};
+ innerMap = outerMap[subkey] = new EmptyObject();
} else if (!Object.hasOwnProperty.call(outerMap, subkey)) {
innerMap = outerMap[subkey] = Object.create(innerMap);
} | false |
Other | emberjs | ember.js | c64b3166dc1d2855266ec2b86a03ec2d786398f1.json | fix silly unnecessary defProp | packages/ember-metal/lib/meta.js | @@ -268,20 +268,25 @@ export function meta(obj, writable) {
return ret || EMPTY_META;
}
- if (obj.__defineNonEnumerable) {
- obj.__defineNonEnumerable(EMBER_META_PROPERTY);
- } else {
- Object.defineProperty(obj, '__ember_meta__', META_DESC);
+ if (ret && ret.source === obj) {
+ return ret;
}
if (!ret) {
ret = new Meta(obj);
if (isEnabled('mandatory-setter')) {
ret.writableValues();
}
- } else if (ret.source !== obj) {
+ } else {
ret = new Meta(obj, ret);
}
+
+ if (obj.__defineNonEnumerable) {
+ obj.__defineNonEnumerable(EMBER_META_PROPERTY);
+ } else {
+ Object.defineProperty(obj, '__ember_meta__', META_DESC);
+ }
obj.__ember_meta__ = ret;
+
return ret;
} | false |
Other | emberjs | ember.js | 84a0a50b618da480588cf0c9e60e0fcd9785fdc3.json | remove outdated comment | packages/ember-metal/lib/meta.js | @@ -99,8 +99,7 @@ function getOrCreateOwnMap(key) {
}
// Implements a member that is a lazily created POJO with inheritable
-// values. For member `thing` you get methods `getThing`,
-// `getOrCreateThing`, and `peekThing`.
+// values.
function inheritedMap(name, Meta) {
let key = memberProperty(name);
let capitalized = capitalize(name); | false |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/alias.js | @@ -7,10 +7,8 @@ import {
defineProperty
} from 'ember-metal/properties';
import { ComputedProperty } from 'ember-metal/computed';
-import {
- meta,
- inspect
-} from 'ember-metal/utils';
+import { inspect } from 'ember-metal/utils';
+import { meta } from 'ember-metal/meta';
import {
addDependentKeys,
removeDependentKeys | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/chains.js | @@ -1,6 +1,6 @@
import Ember from 'ember-metal/core'; // warn, assert, etc;
import { get, normalizeTuple } from 'ember-metal/property_get';
-import { meta as metaFor } from 'ember-metal/utils';
+import { meta as metaFor } from 'ember-metal/meta';
import { watchKey, unwatchKey } from 'ember-metal/watch_key';
var FIRST_KEY = /^([^\.]+)/; | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/computed.js | @@ -1,9 +1,7 @@
import Ember from 'ember-metal/core';
import { set } from 'ember-metal/property_set';
-import {
- meta,
- inspect
-} from 'ember-metal/utils';
+import { inspect } from 'ember-metal/utils';
+import { meta } from 'ember-metal/meta';
import expandProperties from 'ember-metal/expand_properties';
import EmberError from 'ember-metal/error';
import { | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/events.js | @@ -9,10 +9,10 @@
*/
import Ember from 'ember-metal/core';
import {
- meta as metaFor,
apply,
applyStr
} from 'ember-metal/utils';
+import { meta as metaFor } from 'ember-metal/meta';
/* listener flags */
var ONCE = 1; | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/meta.js | @@ -18,17 +18,29 @@ import isEnabled from 'ember-metal/features';
`writable` variants will give you a mutable object, and they will
create it if it didn't already exist.
+ The following methods will get generated metaprogrammatically, and
+ I'm including them here for greppability:
+
+ writableCache, readableCache, writableWatching, readableWatching,
+ peekWatching, clearWatching, writableMixins, readableMixins,
+ peekMixins, clearMixins, writableBindings, readableBindings,
+ peekBindings, clearBindings, writableValues, readableValues,
+ peekValues, clearValues, writableListeners, readableListeners,
+ getAllListeners, writableDeps, readableDeps, getAllDeps
+ writableChainWatchers, readableChainWatchers, writableChains,
+ readableChains
+
*/
let members = {
- cache: ownMap, // writableCache, readableCache
- watching: inheritedMap, // writableWatching, readableWatching, peekWatching, clearWatching
- mixins: inheritedMap, // writableMixins, readableMixins, peekMixins, clearMixins
- bindings: inheritedMap, // writableBindings, readableBindings, peekBindings, clearBindings
- values: inheritedMap, // writableValues, readableValues, peekValues, clearValues
- listeners: inheritedMapOfLists, // writableListeners, readableListeners, getAllListeners
- deps: inheritedMapOfMaps, // writableDeps, readableDeps, getAllDeps
- chainWatchers: ownCustomObject, // writableChainWatchers, readableChainWatchers
- chains: inheritedCustomObject // writableChains, readableChains
+ cache: ownMap,
+ watching: inheritedMap,
+ mixins: inheritedMap,
+ bindings: inheritedMap,
+ values: inheritedMap,
+ listeners: inheritedMapOfLists,
+ deps: inheritedMapOfMaps,
+ chainWatchers: ownCustomObject,
+ chains: inheritedCustomObject
};
let memberNames = Object.keys(members);
@@ -76,7 +88,7 @@ function ownMap(name, Meta) {
function getOrCreateOwnMap(key) {
let ret = this[key];
if (!ret) {
- ret = this[key] = Object.create(null);
+ ret = this[key] = {};
}
return ret;
}
@@ -104,7 +116,7 @@ function inheritedMap(name, Meta) {
};
Meta.prototype['clear' + capitalized] = function() {
- this[key] = Object.create(null);
+ this[key] = {};
};
}
@@ -114,7 +126,7 @@ function getOrCreateInheritedMap(key) {
if (this.parent) {
ret = this[key] = Object.create(getOrCreateInheritedMap.call(this.parent, key));
} else {
- ret = this[key] = Object.create(null);
+ ret = this[key] = {};
}
}
return ret;
@@ -170,7 +182,7 @@ function inheritedMapOfMaps(name, Meta) {
let outerMap = getOrCreateInheritedMap.call(this, key);
let innerMap = outerMap[subkey];
if (!innerMap) {
- innerMap = outerMap[subkey] = Object.create(null);
+ innerMap = outerMap[subkey] = {};
} else if (!Object.hasOwnProperty.call(outerMap, subkey)) {
innerMap = outerMap[subkey] = Object.create(innerMap);
} | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/mixin.js | @@ -14,10 +14,10 @@ import { get } from 'ember-metal/property_get';
import { set, trySet } from 'ember-metal/property_set';
import {
guidFor,
- meta as metaFor,
wrap,
makeArray
} from 'ember-metal/utils';
+import { meta as metaFor } from 'ember-metal/meta';
import expandProperties from 'ember-metal/expand_properties';
import {
Descriptor, | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/properties.js | @@ -4,7 +4,7 @@
import Ember from 'ember-metal/core';
import isEnabled from 'ember-metal/features';
-import { meta as metaFor } from 'ember-metal/utils';
+import { meta as metaFor } from 'ember-metal/meta';
import { overrideChains } from 'ember-metal/property_events';
// ..........................................................
// DESCRIPTOR | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/utils.js | @@ -3,8 +3,6 @@
//
'REMOVE_USE_STRICT: true';
-import { meta } from 'ember-metal/meta';
-
/**
@module ember-metal
*/
@@ -500,6 +498,5 @@ export function applyStr(t, m, a) {
export {
GUID_KEY,
makeArray,
- canInvoke,
- meta // this is temporary until I can refactor all the import sites
+ canInvoke
}; | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/watch_key.js | @@ -1,7 +1,7 @@
import isEnabled from 'ember-metal/features';
import {
meta as metaFor
-} from 'ember-metal/utils';
+} from 'ember-metal/meta';
import {
MANDATORY_SETTER_FUNCTION,
DEFAULT_GETTER_FUNCTION | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/lib/watch_path.js | @@ -1,6 +1,6 @@
import {
meta as metaFor
-} from 'ember-metal/utils';
+} from 'ember-metal/meta';
import { ChainNode } from 'ember-metal/chains';
// get the chains for the current object. If the current object has | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/tests/accessors/mandatory_setters_test.js | @@ -2,7 +2,7 @@ import isEnabled from 'ember-metal/features';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
import { watch } from 'ember-metal/watching';
-import { meta as metaFor } from 'ember-metal/utils';
+import { meta as metaFor } from 'ember-metal/meta';
QUnit.module('mandatory-setters');
| true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/tests/alias_test.js | @@ -2,7 +2,7 @@ import alias from 'ember-metal/alias';
import { defineProperty } from 'ember-metal/properties';
import { get } from 'ember-metal/property_get';
import { set } from 'ember-metal/property_set';
-import { meta } from 'ember-metal/utils';
+import { meta } from 'ember-metal/meta';
import { isWatching } from 'ember-metal/watching';
import { addObserver, removeObserver } from 'ember-metal/observer';
| true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/tests/events_test.js | @@ -1,5 +1,5 @@
import { Mixin } from 'ember-metal/mixin';
-import { meta } from 'ember-metal/utils';
+import { meta } from 'ember-metal/meta';
import {
on, | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-metal/tests/meta_test.js | @@ -61,7 +61,7 @@ QUnit.skip('meta.listeners basics', function(assert) {
let matching = m.matchingListeners(e => e.eventName === 'hello');
assert.equal(matching.length, 1);
assert.equal(matching[0].target, t);
- m.removeFromListeners({ eventName: 'hello', target: t, method: 'm'});
+ m.removeFromListeners({ eventName: 'hello', target: t, method: 'm' });
matching = m.matchingListeners(e => e.eventName === 'hello');
assert.equal(matching.length, 0);
});
@@ -78,7 +78,7 @@ QUnit.skip('meta.listeners inheritance', function(assert) {
let matching = m.matchingListeners(e => e.eventName === 'hello');
assert.equal(matching.length, 1);
assert.equal(matching[0].target, target);
- m.removeFromListeners({ eventName: 'hello', target, method: 'm'});
+ m.removeFromListeners({ eventName: 'hello', target, method: 'm' });
matching = m.matchingListeners(e => e.eventName === 'hello');
assert.equal(matching.length, 0);
}); | true |
Other | emberjs | ember.js | c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json | point everything at the new meta module | packages/ember-runtime/lib/mixins/-proxy.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 { meta } from 'ember-metal/utils';
+import { meta } from 'ember-metal/meta';
import {
addObserver,
removeObserver, | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.