From 8b3e86f2c6720549bc5fb85f4ef7722029a792c2 Mon Sep 17 00:00:00 2001 From: robjacobs Date: Tue, 16 Feb 2016 16:11:21 -0500 Subject: [PATCH] fix(position): getRawNode to handle select/ul elem The getRawNode function was not returning the correct object for collection elements (select, ul, etc...). Closes #5491 Fixes #5354 --- src/position/position.js | 2 +- src/position/test/position.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/position/position.js b/src/position/position.js index 4b78b604b4..311859b940 100644 --- a/src/position/position.js +++ b/src/position/position.js @@ -33,7 +33,7 @@ angular.module('ui.bootstrap.position', []) * @returns {element} A HTML element. */ getRawNode: function(elem) { - return elem[0] || elem; + return elem.nodeName ? elem : elem[0] || elem; }, /** diff --git a/src/position/test/position.spec.js b/src/position/test/position.spec.js index 07e38f95d3..b627876cee 100644 --- a/src/position/test/position.spec.js +++ b/src/position/test/position.spec.js @@ -41,6 +41,20 @@ describe('$uibPosition service', function () { }); }); + describe('rawnode', function() { + it('returns the raw DOM element from an angular element', function() { + var angularEl = angular.element('
'); + var el = $uibPosition.getRawNode(angularEl); + expect(el.nodeName).toBe('DIV'); + }); + + it('returns the raw DOM element from a select element', function() { + var angularEl = angular.element(''); + var el = $uibPosition.getRawNode(angularEl); + expect(el.nodeName).toBe('SELECT'); + }); + }); + describe('offset', function() { it('returns getBoundingClientRect by default', function() { var el = angular.element('
Foo
');