Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 8b3e86f

Browse files
RobJacobsdeeg
authored andcommitted
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
1 parent 4178500 commit 8b3e86f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/position/position.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ angular.module('ui.bootstrap.position', [])
3333
* @returns {element} A HTML element.
3434
*/
3535
getRawNode: function(elem) {
36-
return elem[0] || elem;
36+
return elem.nodeName ? elem : elem[0] || elem;
3737
},
3838

3939
/**

src/position/test/position.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ describe('$uibPosition service', function () {
4141
});
4242
});
4343

44+
describe('rawnode', function() {
45+
it('returns the raw DOM element from an angular element', function() {
46+
var angularEl = angular.element('<div></div>');
47+
var el = $uibPosition.getRawNode(angularEl);
48+
expect(el.nodeName).toBe('DIV');
49+
});
50+
51+
it('returns the raw DOM element from a select element', function() {
52+
var angularEl = angular.element('<select><option value="value">value</option></select>');
53+
var el = $uibPosition.getRawNode(angularEl);
54+
expect(el.nodeName).toBe('SELECT');
55+
});
56+
});
57+
4458
describe('offset', function() {
4559
it('returns getBoundingClientRect by default', function() {
4660
var el = angular.element('<div>Foo</div>');

0 commit comments

Comments
 (0)