Skip to content

Commit

Permalink
increase MessageChannel priority in $.task, close #95
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Aug 6, 2015
1 parent 24ff8bb commit a6bee17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions library/modules/$.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(!setTask || !clearTask){
queue[++counter] = function(){
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
defer(counter + '');
return counter;
};
clearTask = function clearImmediate(id){
Expand All @@ -42,19 +42,19 @@ if(!setTask || !clearTask){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Modern browsers, skip implementation for WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
defer = function(id){
global.postMessage(id, '*');
};
global.addEventListener('message', listner, false);
// WebWorkers
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
port = channel.port2;
channel.port1.onmessage = listner;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScript){
defer = function(id){
global.postMessage(id, '*');
};
global.addEventListener('message', listner, false);
// IE8-
} else if(ONREADYSTATECHANGE in cel('script')){
defer = function(id){
Expand Down
18 changes: 9 additions & 9 deletions modules/$.task.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(!setTask || !clearTask){
queue[++counter] = function(){
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
defer(counter + '');
return counter;
};
clearTask = function clearImmediate(id){
Expand All @@ -42,19 +42,19 @@ if(!setTask || !clearTask){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Modern browsers, skip implementation for WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
defer = function(id){
global.postMessage(id, '*');
};
global.addEventListener('message', listner, false);
// WebWorkers
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
port = channel.port2;
channel.port1.onmessage = listner;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScript){
defer = function(id){
global.postMessage(id, '*');
};
global.addEventListener('message', listner, false);
// IE8-
} else if(ONREADYSTATECHANGE in cel('script')){
defer = function(id){
Expand Down

0 comments on commit a6bee17

Please sign in to comment.