From d87fa0042375b025b98c40bff05e5f42c00af114 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 24 Jul 2013 16:42:52 -0700 Subject: fix(select): don't support binding to select[multiple] changing the type of select box from single to multiple or the other way around at runtime is currently not supported and the two-way binding does odd stuff when such situation happens. we might eventually support this, but for now we are just going to not allow binding to select[multiple] to prevent people from relying on something that doesn't work. BREAKING CHANGE: binding to select[multiple] directly or via ngMultiple (ng-multiple) directive is not supported. This feature never worked with two-way data-binding, so it's not expected that anybody actually depends on it. Closes #3230 --- src/ng/compile.js | 5 +++++ src/ng/directive/booleanAttrs.js | 39 +++------------------------------------ 2 files changed, 8 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/ng/compile.js b/src/ng/compile.js index 46ebe71a..c059af47 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1220,6 +1220,11 @@ function $CompileProvider($provide) { if (!interpolateFn) return; + if (name === "multiple" && nodeName_(node) === "SELECT") { + throw new $compileMinErr("selmulti", "Binding to the multiple attribute is not supported. Element: {0}", + startingTag(node)); + } + directives.push({ priority: 100, compile: valueFn(function attrInterpolateLinkFn(scope, element, attr) { diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js index 8f7399a6..a0966da7 100644 --- a/src/ng/directive/booleanAttrs.js +++ b/src/ng/directive/booleanAttrs.js @@ -199,42 +199,6 @@ */ -/** - * @ngdoc directive - * @name ng.directive:ngMultiple - * @restrict A - * - * @description - * The HTML specs do not require browsers to preserve the special attributes such as multiple. - * (The presence of them means true and absence means false) - * This prevents the angular compiler from correctly retrieving the binding expression. - * To solve this problem, we introduce the `ngMultiple` directive. - * - * @example - - - Check me check multiple:
- -
- - it('should toggle multiple', function() { - expect(element('.doc-example-live #select').prop('multiple')).toBeFalsy(); - input('checked').check(); - expect(element('.doc-example-live #select').prop('multiple')).toBeTruthy(); - }); - -
- * - * @element SELECT - * @param {expression} ngMultiple Angular expression that will be evaluated. - */ - - /** * @ngdoc directive * @name ng.directive:ngReadonly @@ -334,6 +298,9 @@ var ngAttributeAliasDirectives = {}; // boolean attrs are evaluated forEach(BOOLEAN_ATTR, function(propName, attrName) { + // binding to multiple is not supported + if (propName == "multiple") return; + var normalized = directiveNormalize('ng-' + attrName); ngAttributeAliasDirectives[normalized] = function() { return { -- cgit v1.2.3