mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
correct hashchange event registration on window
This commit is contained in:
parent
e160944bfa
commit
5a3c9190dc
2 changed files with 30 additions and 1 deletions
|
|
@ -132,7 +132,7 @@ function JQLiteAddClass(element, selector ) {
|
|||
|
||||
function JQLiteAddNodes(root, elements) {
|
||||
if (elements) {
|
||||
elements = (!elements.nodeName && isDefined(elements.length))
|
||||
elements = (!elements.nodeName && isDefined(elements.length) && !isWindow(elements))
|
||||
? elements
|
||||
: [ elements ];
|
||||
for(var i=0; i < elements.length; i++) {
|
||||
|
|
|
|||
|
|
@ -224,6 +224,35 @@ describe('jqLite', function(){
|
|||
});
|
||||
|
||||
describe('bind', function(){
|
||||
it('should bind to window on hashchange', function(){
|
||||
if (jqLite.fn) return; // don't run in jQuery
|
||||
var eventFn;
|
||||
var window = {
|
||||
document: {},
|
||||
location: {},
|
||||
alert: noop,
|
||||
setInterval: noop,
|
||||
length:10, // pretend you are an array
|
||||
addEventListener: function(type, fn){
|
||||
expect(type).toEqual('hashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
removeEventListener: noop,
|
||||
attachEvent: function(type, fn){
|
||||
expect(type).toEqual('onhashchange');
|
||||
eventFn = fn;
|
||||
},
|
||||
detachEvent: noop
|
||||
};
|
||||
var log;
|
||||
var jWindow = jqLite(window).bind('hashchange', function(){
|
||||
log = 'works!';
|
||||
});
|
||||
eventFn({});
|
||||
expect(log).toEqual('works!');
|
||||
dealoc(jWindow);
|
||||
});
|
||||
|
||||
it('should bind to all elements and return functions', function(){
|
||||
var selected = jqLite([a, b]);
|
||||
var log = '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue