mirror of
https://github.com/liriliri/eruda.git
synced 2026-04-01 10:18:35 +08:00
Dev: Modernizr lazy init
This commit is contained in:
@@ -69,6 +69,7 @@
|
||||
td {
|
||||
padding: 5px 10px;
|
||||
&.key {
|
||||
white-space: nowrap;
|
||||
color: $red-dark;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,20 @@ export default class Features extends Tool
|
||||
this.name = 'features';
|
||||
this._tpl = require('./Features.hbs');
|
||||
this._features = {};
|
||||
this._isInit = false;
|
||||
}
|
||||
init($el)
|
||||
show()
|
||||
{
|
||||
super.init($el);
|
||||
super.show();
|
||||
|
||||
this._initFeatures();
|
||||
if (!this._isInit) this._initFeatures();
|
||||
}
|
||||
_initFeatures()
|
||||
{
|
||||
this._isInit = true;
|
||||
|
||||
modernizr.testRunner();
|
||||
|
||||
util.each(featureNames, (feature) =>
|
||||
{
|
||||
if (specialNames[feature]) feature = specialNames[feature];
|
||||
|
||||
@@ -5,6 +5,10 @@ var featureList = require('./featureList.json');
|
||||
|
||||
modernizr.build(featureList, function (result)
|
||||
{
|
||||
result = result.replace(';(function(window, document, undefined){', '')
|
||||
.replace('window.Modernizr = Modernizr;', '')
|
||||
.replace('testRunner();', 'Modernizr.testRunner = testRunner;')
|
||||
.replace('})(window, document);', '');
|
||||
result += '\nmodule.exports = Modernizr;';
|
||||
fs.writeFile('./modernizr.js', result, 'utf8');
|
||||
});
|
||||
@@ -22,7 +22,7 @@
|
||||
* of control over the experience.
|
||||
*/
|
||||
|
||||
;(function(window, document, undefined){
|
||||
|
||||
var tests = [];
|
||||
|
||||
|
||||
@@ -1275,7 +1275,7 @@ to be the File object's prototype.)
|
||||
* version of that property that the browser actually supports.
|
||||
*
|
||||
* For example, in older Firefox...
|
||||
* ```
|
||||
* ```js
|
||||
* prefixed('boxSizing')
|
||||
* ```
|
||||
* returns 'MozBoxSizing'
|
||||
@@ -2833,7 +2833,7 @@ Modernizr.video.ogg // 'probably'
|
||||
|
||||
|
||||
// Run each test
|
||||
testRunner();
|
||||
Modernizr.testRunner = testRunner;
|
||||
|
||||
delete ModernizrProto.addTest;
|
||||
delete ModernizrProto.addAsyncTest;
|
||||
@@ -2844,10 +2844,10 @@ Modernizr.video.ogg // 'probably'
|
||||
}
|
||||
|
||||
// Leak Modernizr namespace
|
||||
window.Modernizr = Modernizr;
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
})(window, document);
|
||||
|
||||
module.exports = Modernizr;
|
||||
@@ -54,6 +54,7 @@
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
white-space: nowrap;
|
||||
height: 40px;
|
||||
span {
|
||||
display: inline-block;
|
||||
line-height: 40px;
|
||||
|
||||
Reference in New Issue
Block a user