diff --git a/src/ng/compile.js b/src/ng/compile.js index 46ebe71a715e..c059af47d3dd 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 8f7399a60af2..a0966da78c94 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 { diff --git a/test/ng/directive/booleanAttrsSpec.js b/test/ng/directive/booleanAttrsSpec.js index 221c04119259..be2dfb6041e5 100644 --- a/test/ng/directive/booleanAttrsSpec.js +++ b/test/ng/directive/booleanAttrsSpec.js @@ -65,16 +65,6 @@ describe('boolean attr directives', function() { })); - it('should bind multiple', inject(function($rootScope, $compile) { - element = $compile('')($rootScope) - $rootScope.isMultiple=false; - $rootScope.$digest(); - expect(element.attr('multiple')).toBeFalsy(); - $rootScope.isMultiple='multiple'; - $rootScope.$digest(); - expect(element.attr('multiple')).toBeTruthy(); - })); - it('should bind open', inject(function($rootScope, $compile) { element = $compile('
')($rootScope) $rootScope.isOpen=false; @@ -84,6 +74,30 @@ describe('boolean attr directives', function() { $rootScope.$digest(); expect(element.attr('open')).toBeTruthy(); })); + + + describe('multiple', function() { + it('should NOT bind to multiple via ngMultiple', inject(function($rootScope, $compile) { + element = $compile('')($rootScope) + $rootScope.isMultiple=false; + $rootScope.$digest(); + expect(element.attr('multiple')).toBeFalsy(); + $rootScope.isMultiple='multiple'; + $rootScope.$digest(); + expect(element.attr('multiple')).toBeFalsy(); // ignore + })); + + + it('should throw an exception if binding to multiple attribute', inject(function($rootScope, $compile) { + if (msie < 9) return; //IE8 doesn't support biding to boolean attributes + + expect(function() { + $compile('') + }).toThrow('[$compile:selmulti] Binding to the multiple attribute is not supported. ' + + 'Element: