From f0e1eb06aa074cf5846b2c9126d374d71115f046 Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Thu, 28 Jan 2016 20:47:36 +0200 Subject: [PATCH 1/3] fix(select): handle corner case of adding options via a custom directive Under specific circumstances (e.g. adding options via a directive with `replace: true` and a structural directive in its template), an error occurred when trying to call `hasAttribute()` on a comment node (which doesn't support that method). This commit fixes it by first checking if `hasAttribute()` is available. Fixes #13874 --- src/ng/directive/select.js | 5 +++-- test/ng/directive/selectSpec.js | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index fdef4d779245..62cfd085c317 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -6,8 +6,9 @@ function chromeHack(optionElement) { // Workaround for https://code.google.com/p/chromium/issues/detail?id=381459 // Adding an ' + + ''); + }).not.toThrow(); + } + ); }); From 359039c03a825c157cf71138204588bc5c6f8abd Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Fri, 29 Jan 2016 13:57:44 +0200 Subject: [PATCH 2/3] fixup 1 --- src/ng/directive/select.js | 10 +++++----- test/ng/directive/selectSpec.js | 12 ++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 62cfd085c317..ebe8bb1fdc60 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -6,9 +6,8 @@ function chromeHack(optionElement) { // Workaround for https://code.google.com/p/chromium/issues/detail?id=381459 // Adding an '); - expect(function() { - compile( - ''); - }).not.toThrow(); + expect(element).toEqualSelect([unknownValue()], '1', '2', '3'); } ); }); From 4691a8fc9fc987bd33643b628d9cf7025ed74c8a Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Fri, 29 Jan 2016 14:28:58 +0200 Subject: [PATCH 3/3] fixup 2 --- src/ng/directive/select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index ebe8bb1fdc60..2a5ed5e205f0 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -81,7 +81,7 @@ var SelectController = // Tell the select control that an option, with the given value, has been added self.addOption = function(value, element) { // Skip comment nodes, as they only pollute the `optionsMap` - if (element.prop('nodeType') === NODE_TYPE_COMMENT) return; + if (element[0].nodeType === NODE_TYPE_COMMENT) return; assertNotHasOwnProperty(value, '"option value"'); if (value === '') {