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

Commit

Permalink
fix(position): getRawNode to handle select/ul elem
Browse files Browse the repository at this point in the history
The getRawNode function was not returning the correct object
for collection elements (select, ul, etc...).

Closes #5491
Fixes #5354
  • Loading branch information
RobJacobs authored and deeg committed Feb 17, 2016
1 parent 4178500 commit 8b3e86f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/position/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

/**
Expand Down
14 changes: 14 additions & 0 deletions src/position/test/position.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div></div>');
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('<select><option value="value">value</option></select>');
var el = $uibPosition.getRawNode(angularEl);
expect(el.nodeName).toBe('SELECT');
});
});

describe('offset', function() {
it('returns getBoundingClientRect by default', function() {
var el = angular.element('<div>Foo</div>');
Expand Down

0 comments on commit 8b3e86f

Please sign in to comment.