Fix: Prevent negative timing data

This commit is contained in:
surunzi
2017-11-16 15:18:33 +08:00
parent b41840f702
commit 5acef5a4f9
4 changed files with 66 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ Eruda 是一个专为手机网页前端设计的调试面板,类似 DevTools
通过CDN使用
```html
<script src="//cdn.bootcss.com/eruda/1.2.6/eruda.min.js"></script>
<script src="//cdn.bootcss.com/eruda/1.3.0/eruda.min.js"></script>
<script>eruda.init();</script>
```

View File

@@ -1743,6 +1743,21 @@ query.stringify({foo: 'bar', eruda: 'true'}); // -> 'foo=bar&eruda=true'
query.parse('name=eruda&name=eustia'); // -> {name: ['eruda', 'eustia']}
```
## ready
Invoke callback when dom is ready, similar to jQuery ready.
|Name|Type |Desc |
|----|--------|-----------------|
|fn |function|Callback function|
```javascript
ready(function ()
{
// It's safe to manipulate dom here.
});
```
## repeat
Repeat string n-times.

View File

@@ -336,7 +336,7 @@ export default class Network extends Tool
if (!cfg.get('disablePerformance'))
{
this._getPerformanceTimingData();
util.ready(() => this._getPerformanceTimingData());
renderData.data = this._performanceTimingData;
renderData.timing = this._performanceTiming;
}

View File

@@ -5401,6 +5401,55 @@ module.exports = (function ()
return exports;
})();
/* ------------------------------ ready ------------------------------ */
_.ready = (function ()
{
/* Invoke callback when dom is ready, similar to jQuery ready.
*
* |Name|Type |Desc |
* |----|--------|-----------------|
* |fn |function|Callback function|
*
* ```javascript
* ready(function ()
* {
* // It's safe to manipulate dom here.
* });
* ```
*/
/* module
* env: browser
* test: browser
*/
var fns = [],
listener,
doc = document,
hack = doc.documentElement.doScroll,
domContentLoaded = 'DOMContentLoaded',
loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
if (!loaded)
{
doc.addEventListener(domContentLoaded, listener = function ()
{
doc.removeEventListener(domContentLoaded, listener);
loaded = 1;
/* eslint-disable no-cond-assign */
while (listener = fns.shift()) listener();
});
}
function exports(fn)
{
loaded ? setTimeout(fn, 0) : fns.push(fn)
}
return exports;
})();
/* ------------------------------ rtrim ------------------------------ */
var rtrim = _.rtrim = (function ()