From 4b5b97295796fa5d53e1b049ce0e8425464fe0fc Mon Sep 17 00:00:00 2001 From: Eric Kelly Date: Sun, 20 Mar 2016 20:10:46 -0400 Subject: [PATCH] [CLEANUP canary] Remove Ember.Select :skull: As requested in https://github.com/emberjs/ember.js/issues/13127: This removes `Ember.Select`. Views were removed from the 2.0 API unless using the ember-legacy-views addon, which is intended to end support after Ember v2.4. This includes `Ember.select`. http://emberjs.com/deprecations/v1.x/#toc_ember-view --- .../lib/system/application.js | 4 - .../tests/system/application_test.js | 10 - .../lib/templates/select-optgroup.hbs | 1 - .../lib/templates/select-option.hbs | 1 - .../ember-htmlbars/lib/templates/select.hbs | 1 - .../tests/compat/view_helper_test.js | 16 - .../integration/select_in_template_test.js | 364 -------- packages/ember-routing/lib/system/dsl.js | 8 +- .../ember-routing/tests/system/dsl_test.js | 36 +- packages/ember-views/lib/index.js | 12 - packages/ember-views/lib/views/select.js | 682 --------------- .../ember-views/tests/views/select_test.js | 806 ------------------ 12 files changed, 2 insertions(+), 1939 deletions(-) delete mode 100644 packages/ember-htmlbars/lib/templates/select-optgroup.hbs delete mode 100644 packages/ember-htmlbars/lib/templates/select-option.hbs delete mode 100644 packages/ember-htmlbars/lib/templates/select.hbs delete mode 100644 packages/ember-htmlbars/tests/integration/select_in_template_test.js delete mode 100644 packages/ember-views/lib/views/select.js delete mode 100644 packages/ember-views/tests/views/select_test.js diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index 03fd17eb993..c614e253356 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -11,7 +11,6 @@ import Controller from 'ember-runtime/controllers/controller'; import { Renderer } from 'ember-metal-views'; import DOMHelper from 'ember-htmlbars/system/dom-helper'; import topLevelViewTemplate from 'ember-htmlbars/templates/top-level-view'; -import SelectView from 'ember-views/views/select'; import { OutletView } from 'ember-routing-views/views/outlet'; import EmberView from 'ember-views/views/view'; import EventDispatcher from 'ember-views/system/event_dispatcher'; @@ -1060,9 +1059,6 @@ Application.reopenClass({ registry.register('renderer:-dom', { create() { return new Renderer(new DOMHelper()); } }); registry.injection('view', 'renderer', 'renderer:-dom'); - if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - registry.register('view:select', SelectView); - } registry.register('view:-outlet', OutletView); registry.register('-view-registry:main', { create() { return {}; } }); diff --git a/packages/ember-application/tests/system/application_test.js b/packages/ember-application/tests/system/application_test.js index 2e8e2198fc0..3d9ce8e6552 100644 --- a/packages/ember-application/tests/system/application_test.js +++ b/packages/ember-application/tests/system/application_test.js @@ -338,16 +338,6 @@ QUnit.test('can specify custom router', function() { ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router'); }); -QUnit.test('registers controls onto to container', function() { - run(function() { - app = Application.create({ - rootElement: '#qunit-fixture' - }); - }); - - ok(app.__container__.lookup('view:select'), 'Select control is registered into views'); -}); - QUnit.test('does not leak itself in onLoad._loaded', function() { equal(_loaded.application, undefined); var app = run(Application, 'create'); diff --git a/packages/ember-htmlbars/lib/templates/select-optgroup.hbs b/packages/ember-htmlbars/lib/templates/select-optgroup.hbs deleted file mode 100644 index ab9475dba3e..00000000000 --- a/packages/ember-htmlbars/lib/templates/select-optgroup.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#each attrs.content as |item|}}{{view attrs.optionView content=item selection=attrs.selection parentValue=attrs.value multiple=attrs.multiple optionLabelPath=attrs.optionLabelPath optionValuePath=attrs.optionValuePath}}{{/each}} \ No newline at end of file diff --git a/packages/ember-htmlbars/lib/templates/select-option.hbs b/packages/ember-htmlbars/lib/templates/select-option.hbs deleted file mode 100644 index 6471e4e9467..00000000000 --- a/packages/ember-htmlbars/lib/templates/select-option.hbs +++ /dev/null @@ -1 +0,0 @@ -{{~view.label~}} diff --git a/packages/ember-htmlbars/lib/templates/select.hbs b/packages/ember-htmlbars/lib/templates/select.hbs deleted file mode 100644 index 64f5912a0be..00000000000 --- a/packages/ember-htmlbars/lib/templates/select.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if view.prompt}}{{/if}}{{#if view.optionGroupPath}}{{#each view.groupedContent as |group|}}{{view view.groupView content=group.content label=group.label selection=view.selection value=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath optionView=view.optionView}}{{/each}}{{else}}{{#each view.content as |item|}}{{view view.optionView content=item selection=view.selection parentValue=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath}}{{/each}}{{/if}} diff --git a/packages/ember-htmlbars/tests/compat/view_helper_test.js b/packages/ember-htmlbars/tests/compat/view_helper_test.js index b6aee90376a..4164a3645ec 100644 --- a/packages/ember-htmlbars/tests/compat/view_helper_test.js +++ b/packages/ember-htmlbars/tests/compat/view_helper_test.js @@ -1,7 +1,6 @@ import Ember from 'ember-metal/core'; import EmberComponent from 'ember-views/components/component'; import EmberView from 'ember-views/views/view'; -import EmberSelectView from 'ember-views/views/select'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import compile from 'ember-template-compiler/system/compile'; import { OWNER } from 'container/owner'; @@ -101,18 +100,3 @@ QUnit.test('using the view helper with a string (block form) fails assertion [LE assert.equal(component.$().text(), 'Foo says: I am foo', 'view helper is still rendered'); }); - -QUnit.test('using the view helper with string "select" fails assertion [LEGACY]', function(assert) { - owner.register('view:select', EmberSelectView); - - ignoreAssertion(function() { - component = EmberComponent.extend({ - [OWNER]: owner, - layout: compile('{{view \'select\'}}') - }).create(); - - runAppend(component); - }); - - assert.ok(!!component.$('select').length, 'still renders select'); -}); diff --git a/packages/ember-htmlbars/tests/integration/select_in_template_test.js b/packages/ember-htmlbars/tests/integration/select_in_template_test.js deleted file mode 100644 index 4c3884ade0d..00000000000 --- a/packages/ember-htmlbars/tests/integration/select_in_template_test.js +++ /dev/null @@ -1,364 +0,0 @@ -import EmberObject from 'ember-runtime/system/object'; -import run from 'ember-metal/run_loop'; -import EmberView from 'ember-views/views/view'; -import EventDispatcher from 'ember-views/system/event_dispatcher'; - -import { computed } from 'ember-metal/computed'; -import Namespace from 'ember-runtime/system/namespace'; -import ArrayProxy from 'ember-runtime/system/array_proxy'; -import { A as emberA } from 'ember-runtime/system/native_array'; -import SelectView from 'ember-views/views/select'; -import compile from 'ember-template-compiler/system/compile'; -import Controller from 'ember-runtime/controllers/controller'; -import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; -import environment from 'ember-metal/environment'; - -import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils'; -import viewKeyword from 'ember-htmlbars/keywords/view'; - -var dispatcher, view, originalViewKeyword; - -QUnit.module('ember-htmlbars: Ember.Select - usage inside templates', { - setup() { - originalViewKeyword = registerKeyword('view', viewKeyword); - dispatcher = EventDispatcher.create(); - dispatcher.setup(); - }, - - teardown() { - runDestroy(dispatcher); - runDestroy(view); - resetKeyword('view', originalViewKeyword); - } -}); - -QUnit.test('works from a template with bindings [DEPRECATED]', function() { - var Person = EmberObject.extend({ - id: null, - firstName: null, - lastName: null, - - fullName: computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }).property('firstName', 'lastName') - }); - - var erik = Person.create({ id: 4, firstName: 'Erik', lastName: 'Bryn' }); - - var application = Namespace.create(); - - application.peopleController = Controller.create({ - content: emberA([ - Person.create({ id: 1, firstName: 'Yehuda', lastName: 'Katz' }), - Person.create({ id: 2, firstName: 'Tom', lastName: 'Dale' }), - Person.create({ id: 3, firstName: 'Peter', lastName: 'Wagenet' }), - erik - ]) - }); - - application.selectedPersonController = EmberObject.create({ - person: null - }); - - view = EmberView.create({ - app: application, - selectView: SelectView, - template: compile( - '{{view view.selectView viewName="select"' + - ' content=view.app.peopleController.content' + - ' optionLabelPath="content.fullName"' + - ' optionValuePath="content.id"' + - ' prompt="Pick a person:"' + - ' selection=view.app.selectedPersonController.person}}' - ) - }); - - runAppend(view); - - var select = view.get('select'); - ok(select.$().length, 'Select was rendered'); - equal(select.$('option').length, 5, 'Options were rendered'); - equal(select.$().text(), 'Pick a person:Yehuda KatzTom DalePeter WagenetErik Bryn\n', 'Option values were rendered'); - equal(select.get('selection'), null, 'Nothing has been selected'); - - run(function() { - application.selectedPersonController.set('person', erik); - }); - - equal(select.get('selection'), erik, 'Selection was updated through binding'); - run(function() { - application.peopleController.get('content').pushObject(Person.create({ id: 5, firstName: 'James', lastName: 'Rosen' })); - }); - - equal(select.$('option').length, 6, 'New option was added'); - equal(select.get('selection'), erik, 'Selection was maintained after new option was added'); -}); - -QUnit.test('works from a template', function() { - var Person = EmberObject.extend({ - id: null, - firstName: null, - lastName: null, - - fullName: computed(function() { - return this.get('firstName') + ' ' + this.get('lastName'); - }).property('firstName', 'lastName') - }); - - var erik = Person.create({ id: 4, firstName: 'Erik', lastName: 'Bryn' }); - - var application = Namespace.create(); - - application.peopleController = Controller.create({ - content: emberA([ - Person.create({ id: 1, firstName: 'Yehuda', lastName: 'Katz' }), - Person.create({ id: 2, firstName: 'Tom', lastName: 'Dale' }), - Person.create({ id: 3, firstName: 'Peter', lastName: 'Wagenet' }), - erik - ]) - }); - - application.selectedPersonController = EmberObject.create({ - person: null - }); - - view = EmberView.create({ - app: application, - selectView: SelectView, - template: compile( - '{{view view.selectView viewName="select"' + - ' content=view.app.peopleController.content' + - ' optionLabelPath="content.fullName"' + - ' optionValuePath="content.id"' + - ' prompt="Pick a person:"' + - ' selection=view.app.selectedPersonController.person}}' - ) - }); - - runAppend(view); - - var select = view.get('select'); - ok(select.$().length, 'Select was rendered'); - equal(select.$('option').length, 5, 'Options were rendered'); - equal(select.$().text(), 'Pick a person:Yehuda KatzTom DalePeter WagenetErik Bryn\n', 'Option values were rendered'); - equal(select.get('selection'), null, 'Nothing has been selected'); - - run(function() { - application.selectedPersonController.set('person', erik); - }); - - equal(select.get('selection'), erik, 'Selection was updated through binding'); - run(function() { - application.peopleController.get('content').pushObject(Person.create({ id: 5, firstName: 'James', lastName: 'Rosen' })); - }); - - equal(select.$('option').length, 6, 'New option was added'); - equal(select.get('selection'), erik, 'Selection was maintained after new option was added'); -}); - -if (!environment.isFirefox) { - // firefox has bugs... - // TODO: figure out a solution - QUnit.test('upon content change, the DOM should reflect the selection (#481)', function() { - var userOne = { name: 'Mike', options: emberA(['a', 'b']), selectedOption: 'a' }; - var userTwo = { name: 'John', options: emberA(['c', 'd']), selectedOption: 'd' }; - - view = EmberView.create({ - user: userOne, - selectView: SelectView, - template: compile( - '{{view view.selectView viewName="select"' + - ' content=view.user.options' + - ' selection=view.user.selectedOption}}' - ) - }); - - runAppend(view); - - var select = view.get('select'); - var selectEl = select.$()[0]; - - equal(select.get('selection'), 'a', 'Precond: Initial selection is correct'); - equal(selectEl.selectedIndex, 0, 'Precond: The DOM reflects the correct selection'); - - run(function() { - view.set('user', userTwo); - }); - - equal(select.get('selection'), 'd', 'Selection was properly set after content change'); - equal(selectEl.selectedIndex, 1, 'The DOM reflects the correct selection'); - }); -} - -QUnit.test('upon content change with Array-like content, the DOM should reflect the selection', function() { - var tom = { id: 4, name: 'Tom' }; - var sylvain = { id: 5, name: 'Sylvain' }; - - var proxy = ArrayProxy.create({ - content: emberA(), - selectedOption: sylvain - }); - - view = EmberView.create({ - proxy: proxy, - selectView: SelectView, - template: compile( - '{{view view.selectView viewName="select"' + - ' content=view.proxy' + - ' selection=view.proxy.selectedOption}}' - ) - }); - - runAppend(view); - - var select = view.get('select'); - var selectEl = select.$()[0]; - - equal(selectEl.selectedIndex, -1, 'Precond: The DOM reflects the lack of selection'); - - run(function() { - proxy.set('content', emberA([tom, sylvain])); - }); - - equal(select.get('selection'), sylvain, 'Selection was properly set after content change'); - equal(selectEl.selectedIndex, 1, 'The DOM reflects the correct selection'); -}); - -function testValueBinding(templateString) { - view = EmberView.create({ - collection: emberA([{ name: 'Wes', value: 'w' }, { name: 'Gordon', value: 'g' }]), - val: 'g', - selectView: SelectView, - template: compile(templateString) - }); - - runAppend(view); - - var select = view.get('select'); - var selectEl = select.$()[0]; - - equal(view.get('val'), 'g', 'Precond: Initial bound property is correct'); - equal(select.get('value'), 'g', 'Precond: Initial selection is correct'); - equal(selectEl.selectedIndex, 2, 'Precond: The DOM reflects the correct selection'); - - select.$('option:eq(2)').removeAttr('selected'); - select.$('option:eq(1)').prop('selected', true); - select.$().trigger('change'); - - equal(view.get('val'), 'w', 'Updated bound property is correct'); - equal(select.get('value'), 'w', 'Updated selection is correct'); - equal(selectEl.selectedIndex, 1, 'The DOM is updated to reflect the new selection'); -} - -QUnit.test('select element should correctly initialize and update selectedIndex and bound properties when using valueBinding [DEPRECATED]', function() { - expectDeprecation(`You're using legacy binding syntax: valueBinding="view.val" (L1:C176) . Please replace with value=view.val`); - - testValueBinding( - '{{view view.selectView viewName="select"' + - ' contentBinding="view.collection"' + - ' optionLabelPath="content.name"' + - ' optionValuePath="content.value"' + - ' prompt="Please wait..."' + - ' valueBinding="view.val"}}' - ); -}); - -QUnit.test('select element should correctly initialize and update selectedIndex and bound properties when using valueBinding', function() { - testValueBinding( - '{{view view.selectView viewName="select"' + - ' content=view.collection' + - ' optionLabelPath="content.name"' + - ' optionValuePath="content.value"' + - ' prompt="Please wait..."' + - ' value=view.val}}' - ); -}); - -function testSelectionBinding(templateString) { - view = EmberView.create({ - collection: emberA([{ name: 'Wes', value: 'w' }, { name: 'Gordon', value: 'g' }]), - selection: { name: 'Gordon', value: 'g' }, - selectView: SelectView, - template: compile(templateString) - }); - - runAppend(view); - - var select = view.get('select'); - var selectEl = select.$()[0]; - - equal(view.get('selection.value'), 'g', 'Precond: Initial bound property is correct'); - equal(select.get('selection.value'), 'g', 'Precond: Initial selection is correct'); - equal(selectEl.selectedIndex, 2, 'Precond: The DOM reflects the correct selection'); - equal(select.$('option:eq(2)').prop('selected'), true, 'Precond: selected property is set to proper option'); - - select.$('option:eq(2)').removeAttr('selected'); - select.$('option:eq(1)').prop('selected', true); - select.$().trigger('change'); - - equal(view.get('selection.value'), 'w', 'Updated bound property is correct'); - equal(select.get('selection.value'), 'w', 'Updated selection is correct'); - equal(selectEl.selectedIndex, 1, 'The DOM is updated to reflect the new selection'); - equal(select.$('option:eq(1)').prop('selected'), true, 'Selected property is set to proper option'); -} - -QUnit.test('select element should correctly initialize and update selectedIndex and bound properties when using selectionBinding [DEPRECATED]', function() { - expectDeprecation(`You're using legacy binding syntax: contentBinding="view.collection" (L1:C44) . Please replace with content=view.collection`); - - testSelectionBinding( - '{{view view.selectView viewName="select"' + - ' contentBinding="view.collection"' + - ' optionLabelPath="content.name"' + - ' optionValuePath="content.value"' + - ' prompt="Please wait..."' + - ' selectionBinding="view.selection"}}' - ); -}); - -QUnit.test('select element should correctly initialize and update selectedIndex and bound properties when using a bound selection', function() { - testSelectionBinding( - '{{view view.selectView viewName="select"' + - ' content=view.collection' + - ' optionLabelPath="content.name"' + - ' optionValuePath="content.value"' + - ' prompt="Please wait..."' + - ' selection=view.selection}}' - ); -}); - -QUnit.test('select element should correctly initialize and update selectedIndex and bound properties when using selectionBinding and optionValuePath with custom path', function() { - var templateString = '{{view view.selectView viewName="select"' + - ' content=view.collection' + - ' optionLabelPath="content.name"' + - ' optionValuePath="content.val"' + - ' prompt="Please wait..."' + - ' selection=view.selection}}'; - - view = EmberView.create({ - collection: emberA([{ name: 'Wes', val: 'w' }, { name: 'Gordon', val: 'g' }]), - selection: { name: 'Gordon', val: 'g' }, - selectView: SelectView, - template: compile(templateString) - }); - - run(function() { - view.appendTo('#qunit-fixture'); - }); - - var select = view.get('select'); - var selectEl = select.$()[0]; - - equal(view.get('selection.val'), 'g', 'Precond: Initial bound property is correct'); - equal(select.get('selection.val'), 'g', 'Precond: Initial selection is correct'); - equal(selectEl.selectedIndex, 2, 'Precond: The DOM reflects the correct selection'); - equal(select.$('option:eq(1)').prop('selected'), false, 'Precond: selected property is set to proper option'); - - select.$('option:eq(2)').removeAttr('selected'); - select.$('option:eq(1)').prop('selected', true); - select.$().trigger('change'); - - equal(view.get('selection.val'), 'w', 'Updated bound property is correct'); - equal(select.get('selection.val'), 'w', 'Updated selection is correct'); - equal(selectEl.selectedIndex, 1, 'The DOM is updated to reflect the new selection'); - equal(select.$('option:eq(1)').prop('selected'), true, 'selected property is set to proper option'); -}); diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js index a7eeaba35eb..292dc719a4d 100644 --- a/packages/ember-routing/lib/system/dsl.js +++ b/packages/ember-routing/lib/system/dsl.js @@ -1,4 +1,4 @@ -import { assert, deprecate, warn } from 'ember-metal/debug'; +import { assert, deprecate } from 'ember-metal/debug'; /** @module ember @@ -36,12 +36,6 @@ DSL.prototype = { })() ); - warn( - `Using a route named 'select' (and defining a App.SelectView) will prevent you from using {{view 'select'}}`, - name !== 'select', - { id: 'ember-routing.dsl-select-route' } - ); - if (this.enableLoadingSubstates) { createRoute(this, `${name}_loading`, { resetNamespace: options.resetNamespace }); createRoute(this, `${name}_error`, { path: dummyErrorRoute }); diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js index b952a6461d2..89ade6025f4 100644 --- a/packages/ember-routing/tests/system/dsl_test.js +++ b/packages/ember-routing/tests/system/dsl_test.js @@ -1,19 +1,12 @@ -/* globals EmberDev */ import EmberRouter from 'ember-routing/system/router'; -import { HANDLERS } from 'ember-debug/handlers'; -import { - registerHandler as registerWarnHandler -} from 'ember-debug/warn'; -var Router, outerWarnHandler; +var Router; QUnit.module('Ember Router DSL', { setup() { Router = EmberRouter.extend(); - outerWarnHandler = HANDLERS.warn; }, teardown() { - HANDLERS.warn = outerWarnHandler; Router = null; } }); @@ -49,33 +42,6 @@ QUnit.test('should fail when using a reserved route name', function() { }); }); -// jscs:disable validateIndentation -if (EmberDev && !EmberDev.runningProdBuild) { - QUnit.test('should warn when using a dangerous select route name', function(assert) { - expect(1); - - var originalWarnHandler = HANDLERS.warn; - - registerWarnHandler(function(message) { - assert.equal(message, - `Using a route named 'select' (and defining a App.SelectView) will prevent you from using {{view 'select'}}`, - 'select route warning is triggered'); - }); - - Router = EmberRouter.extend(); - - Router.map(function() { - this.route('select'); - }); - - var router = Router.create(); - router._initRouterJs(); - - HANDLERS.warn = originalWarnHandler; - }); -} -// jscs:enable validateIndentation - QUnit.test('should reset namespace if nested with resource', function() { expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); diff --git a/packages/ember-views/lib/index.js b/packages/ember-views/lib/index.js index 9fd35eed48c..ca36ef71f20 100644 --- a/packages/ember-views/lib/index.js +++ b/packages/ember-views/lib/index.js @@ -32,11 +32,6 @@ import TextSupport from 'ember-views/mixins/text_support'; import TextField from 'ember-views/views/text_field'; import TextArea from 'ember-views/views/text_area'; -import { - Select, - SelectOption, - SelectOptgroup -} from 'ember-views/views/select'; import _MetamorphView, { _Metamorph } from 'ember-views/compat/metamorph_view'; import LegacyEachView from 'ember-views/views/legacy_each_view'; @@ -76,13 +71,6 @@ Ember.Checkbox = Checkbox; Ember.TextField = TextField; Ember.TextArea = TextArea; -if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - Ember.Select = Select; -} - -Ember.SelectOption = SelectOption; -Ember.SelectOptgroup = SelectOptgroup; - Ember.TextSupport = TextSupport; Ember.ComponentLookup = ComponentLookup; Ember.Component = Component; diff --git a/packages/ember-views/lib/views/select.js b/packages/ember-views/lib/views/select.js deleted file mode 100644 index a3a63a4f294..00000000000 --- a/packages/ember-views/lib/views/select.js +++ /dev/null @@ -1,682 +0,0 @@ -/** -@module ember -@submodule ember-views -*/ - -import replace from 'ember-metal/replace'; -import { get } from 'ember-metal/property_get'; -import { set } from 'ember-metal/property_set'; -import View from 'ember-views/views/view'; -import { isArray } from 'ember-runtime/utils'; -import isNone from 'ember-metal/is_none'; -import { computed } from 'ember-metal/computed'; -import { A as emberA } from 'ember-runtime/system/native_array'; -import { observer } from 'ember-metal/mixin'; -import { defineProperty } from 'ember-metal/properties'; - -import htmlbarsTemplate from 'ember-htmlbars/templates/select'; -import selectOptionDefaultTemplate from 'ember-htmlbars/templates/select-option'; -import selectOptgroupDefaultTemplate from 'ember-htmlbars/templates/select-optgroup'; - -import { objectAt } from 'ember-runtime/mixins/array'; - -var defaultTemplate = htmlbarsTemplate; - -var SelectOption = View.extend({ - instrumentDisplay: 'Ember.SelectOption', - - tagName: 'option', - attributeBindings: ['value', 'selected'], - - defaultTemplate: selectOptionDefaultTemplate, - - content: null, - - _willRender() { - this.labelPathDidChange(); - this.valuePathDidChange(); - }, - - selected: computed('attrs.content', 'attrs.selection', function() { - var value = get(this, 'value'); - var selection = get(this, 'attrs.selection'); - if (get(this, 'attrs.multiple')) { - return selection && selection.indexOf(value) > -1; - } else { - // Primitives get passed through bindings as objects... since - // `new Number(4) !== 4`, we use `==` below - return value == get(this, 'attrs.parentValue'); // jshint ignore:line - } - }), - - labelPathDidChange: observer('attrs.optionLabelPath', function() { - var labelPath = get(this, 'attrs.optionLabelPath'); - defineProperty(this, 'label', computed.alias(labelPath)); - }), - - valuePathDidChange: observer('attrs.optionValuePath', function() { - var valuePath = get(this, 'attrs.optionValuePath'); - defineProperty(this, 'value', computed.alias(valuePath)); - }) -}); - -var SelectOptgroup = View.extend({ - instrumentDisplay: 'Ember.SelectOptgroup', - - tagName: 'optgroup', - defaultTemplate: selectOptgroupDefaultTemplate, - attributeBindings: ['label'] -}); - -/** - The `Ember.Select` view class renders a - [select](https://developer.mozilla.org/en/HTML/Element/select) HTML element, - allowing the user to choose from a list of options. - - The text and `value` property of each ` - - - ``` - - The `value` attribute of the selected `