Skip to content

Commit

Permalink
update util
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Jul 15, 2014
1 parent 84f0b1e commit b26efde
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 55 deletions.
41 changes: 23 additions & 18 deletions build/util-debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright 2014, KISSY v5.0.0
MIT Licensed
build time: Jul 1 22:55
build time: Jul 15 20:52
*/
/*
combined modules:
Expand Down Expand Up @@ -919,9 +919,8 @@ KISSY.add('util/object', [
* when naming packages. Reserved words may work in some browsers and not others.
*
* @example
* util.namespace('KISSY.app'); // returns KISSY.app
* util.namespace('app.Shop',a); // returns a.app.Shop
* util.namespace('TB.app.Shop'); // returns TB.app.Shop
* util.namespace('app.Shop'); // returns app.Shop
*
* @return {Object} A reference to the last namespace object created
* @member KISSY
Expand Down Expand Up @@ -1473,13 +1472,16 @@ KISSY.add('util/web', [
*/
ready: function (fn) {
if (domReady) {
try {
fn(KISSY);
} catch (e) {
LoggerManager.log(e.stack || e, 'error');
setTimeout(function () {
throw e;
}, 0);
if ('@DEBUG@') {
fn();
} else {
try {
fn();
} catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
}
} else {
callbacks.push(fn);
Expand Down Expand Up @@ -1519,14 +1521,17 @@ KISSY.add('util/web', [
}
domReady = 1;
for (var i = 0; i < callbacks.length; i++) {
try {
callbacks[i](KISSY);
} catch (e) {
LoggerManager.log(e.stack || e, 'error'); /*jshint loopfunc:true*/
/*jshint loopfunc:true*/
setTimeout(function () {
throw e;
}, 0);
if ('@DEBUG@') {
callbacks[i]();
} else {
try {
callbacks[i]();
} catch (e) {
/*jshint loopfunc:true*/
setTimeout(function () {
throw e;
}, 0);
}
}
}
} // Binds ready events.
Expand Down
8 changes: 4 additions & 4 deletions build/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 23 additions & 18 deletions lib/build/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copyright 2014, KISSY v5.0.0
MIT Licensed
build time: Jul 1 22:55
build time: Jul 15 20:52
*/
/*
combined modules:
Expand Down Expand Up @@ -919,9 +919,8 @@ KISSY.add('util/object', [
* when naming packages. Reserved words may work in some browsers and not others.
*
* @example
* util.namespace('KISSY.app'); // returns KISSY.app
* util.namespace('app.Shop',a); // returns a.app.Shop
* util.namespace('TB.app.Shop'); // returns TB.app.Shop
* util.namespace('app.Shop'); // returns app.Shop
*
* @return {Object} A reference to the last namespace object created
* @member KISSY
Expand Down Expand Up @@ -1473,13 +1472,16 @@ KISSY.add('util/web', [
*/
ready: function (fn) {
if (domReady) {
try {
fn(KISSY);
} catch (e) {
LoggerManager.log(e.stack || e, 'error');
setTimeout(function () {
throw e;
}, 0);
if ('@DEBUG@') {
fn();
} else {
try {
fn();
} catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
}
} else {
callbacks.push(fn);
Expand Down Expand Up @@ -1519,14 +1521,17 @@ KISSY.add('util/web', [
}
domReady = 1;
for (var i = 0; i < callbacks.length; i++) {
try {
callbacks[i](KISSY);
} catch (e) {
LoggerManager.log(e.stack || e, 'error'); /*jshint loopfunc:true*/
/*jshint loopfunc:true*/
setTimeout(function () {
throw e;
}, 0);
if ('@DEBUG@') {
callbacks[i]();
} else {
try {
callbacks[i]();
} catch (e) {
/*jshint loopfunc:true*/
setTimeout(function () {
throw e;
}, 0);
}
}
}
} // Binds ready events.
Expand Down
3 changes: 1 addition & 2 deletions src/util/src/util/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,8 @@ mix(util, {
* when naming packages. Reserved words may work in some browsers and not others.
*
* @example
* util.namespace('KISSY.app'); // returns KISSY.app
* util.namespace('app.Shop',a); // returns a.app.Shop
* util.namespace('TB.app.Shop'); // returns TB.app.Shop
* util.namespace('app.Shop'); // returns app.Shop
*
* @return {Object} A reference to the last namespace object created
* @member KISSY
Expand Down
8 changes: 4 additions & 4 deletions src/util/src/util/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ util.mix(util, {
ready: function (fn) {
if (domReady) {
if ('@DEBUG@') {
fn(KISSY);
fn();
} else {
try {
fn(KISSY);
fn();
} catch (e) {
setTimeout(function () {
throw e;
Expand Down Expand Up @@ -162,10 +162,10 @@ function fireReady() {
domReady = 1;
for (var i = 0; i < callbacks.length; i++) {
if ('@DEBUG@') {
callbacks[i](KISSY);
callbacks[i]();
} else {
try {
callbacks[i](KISSY);
callbacks[i]();
} catch (e) {
/*jshint loopfunc:true*/
setTimeout(function () {
Expand Down
21 changes: 12 additions & 9 deletions src/util/tests/specs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ var util = require('util');
var UA = require('ua');
/*jshint quotmark:false*/
describe('util', function () {
var host = S.Env.host,
doc = host.document,
web = host.setInterval;
var host = typeof window !== undefined ? window : '';
if (!host) {
return;
}
var doc = host.document;
var web = host.setInterval;

function fn() {
}
Expand Down Expand Up @@ -1048,13 +1051,13 @@ describe('util', function () {
describe("util.ready", function () {
it('util.ready simple works', function () {
var r;
util.ready(function (s) {
r = s;
util.ready(function () {
r = 1;
});

waits(100);
runs(function () {
expect(r).toBe(S);
expect(r).toBe(1);
});
});

Expand All @@ -1066,13 +1069,13 @@ describe('util', function () {
throw "1";
});

util.ready(function (s) {
r = s;
util.ready(function () {
r = 1;
});

waits(100);
runs(function () {
expect(r).toBe(S);
expect(r).toBe(1);
});
});
}
Expand Down

0 comments on commit b26efde

Please sign in to comment.