Dev: Modernizr lazy init

This commit is contained in:
surunzi
2016-05-17 00:57:13 +08:00
parent da5d51b89c
commit d1e60422c7
5 changed files with 19 additions and 8 deletions

View File

@@ -69,6 +69,7 @@
td {
padding: 5px 10px;
&.key {
white-space: nowrap;
color: $red-dark;
}
}

View File

@@ -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];

View File

@@ -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');
});

View File

@@ -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;

View File

@@ -54,6 +54,7 @@
overflow-x: auto;
-webkit-overflow-scrolling: touch;
white-space: nowrap;
height: 40px;
span {
display: inline-block;
line-height: 40px;