convert jshint and jscs to eslint (#2044)

This commit is contained in:
patrick kettner
2016-07-31 20:47:05 +04:00
committed by GitHub
parent 8823422559
commit 6b26daeee8
49 changed files with 4674 additions and 4452 deletions

70
.eslintrc Normal file
View File

@@ -0,0 +1,70 @@
{
"preset": "google",
"jsDoc": {
"requireHyphenBeforeDescription": true,
"requireNewlineAfterDescription": true,
"checkRedundantReturns": true,
"checkParamExistence": true,
"requireReturnTypes": true,
"requireParamTypes": true,
"checkReturnTypes": true,
"checkTypes": true,
"checkAnnotations": {
"preset": "jsdoc3",
"extra": {
"access": true,
"optionName": true,
"optionProp": true,
"memberof": true
}
}
},
"env": {
"browser": true,
"node": true,
"mocha": true,
"es6": true,
"amd": true
},
"globals": {
"DocumentTouch": true,
"Modernizr": true,
"requirejs": true,
"expect": true,
"$": true,
"_": true
},
"rules": {
"indent": [
2,
2,
{
"SwitchCase": 1
}
],
"quotes": [
"error",
"single"
],
"curly": "off",
"wrap-iife": "off",
"no-caller": "error",
"no-cond-assign": [
"error",
"except-parens"
],
"eqeqeq": "off",
"no-eq-null": "error",
"new-cap": "off",
"no-undef": "error",
"no-unused-vars": "error",
"no-unused-expressions": "error",
"no-eval": "error",
"comma-style": [
"error",
"last"
],
"dot-notation": "off",
"valid-jsdoc": "error"
}
}

28
.jscsrc
View File

@@ -1,28 +0,0 @@
{
"preset": "google",
"disallowKeywordsOnNewLine": null,
"disallowMultipleVarDecl": null,
"disallowMultipleLineBreaks": null,
"maximumLineLength": null,
"requireCamelCaseOrUpperCaseIdentifiers": null,
"validateIndentation": null,
"jsDoc": {
"requireHyphenBeforeDescription": true,
"requireNewlineAfterDescription": true,
"checkRedundantReturns": true,
"checkParamExistence": true,
"requireReturnTypes": true,
"requireParamTypes": true,
"checkReturnTypes": true,
"checkTypes": true,
"checkAnnotations": {
"preset": "jsdoc3",
"extra": {
"access": true,
"optionName": true,
"optionProp": true,
"memberof": true,
}
}
}
}

View File

@@ -1,95 +0,0 @@
{
/*
* ENVIRONMENTS
* =================
*/
// Define globals exposed by modern browsers.
"browser": true,
"node": true,
/*
* TABS AND QUOTES
* ==================
*/
// Enforce tab width of 2 spaces.
"indent": 2,
// Enforce use of single quotation marks for strings.
"quotmark": "single",
/*
* ENFORCING OPTIONS
* =================
*/
// This option allows you to not put curly braces
// around blocks in loops and conditionals.
"curly": false,
// This option allows the use of immediate function
// invocations without wrapping them in parentheses.
"immed": false,
// This option prohibits the use of arguments.caller
// and arguments.callee. Both .caller and .callee make
// quite a few optimizations impossible so they were
// deprecated in future versions of JavaScript.
"noarg": true,
// This option suppresses warnings about the use of
// assignments in cases where comparisons are expected
"boss": true,
// Allow use of == and != in favor of === and !==.
"eqeqeq": false,
// Suppress warnings about == null comparisons.
"eqnull": true,
// Does not require capitalized names for constructor functions.
"newcap": false,
// Prohibit trailing whitespace.
"trailing": true,
// Prohibit use of explicitly undeclared variables.
"undef": true,
// Warn when variables are defined but never used.
"unused": true,
// This option suppresses warnings about the use of expressions where
// normally you would expect to see assignments or function calls.
// Most of the time, such code is a typo. However, it is not forbidden
// by the spec and that's why this warning is optional.
"expr": true,
// This option suppresses warnings about the use of eval.
// The use of eval is discouraged because it can make your code
// vulnerable to various injection attacks and it makes it hard for
// JavaScript interpreter to do certain optimizations.
"evil": true,
// This option suppresses warnings about comma-first coding style.
"laxcomma": true,
// suppress object dot notation warnings, we know what we're doing
"sub": true,
// This option defines globals that are usually used for logging poor-man's
// debugging: console, alert, etc. It is usually a good idea to not ship
// them in production because, for example, console.log breaks in legacy
// versions of Internet Explorer.
"devel": true,
// This option suppresses warnings about mixed tabs and spaces when the
// latter are used for alignment only. The technique is called SmartTabs.
"smarttabs": true,
"globals": {
"DocumentTouch": true,
"Modernizr": true,
"define": true
}
}

View File

@@ -50,8 +50,12 @@ module.exports = function(grunt) {
]
}
},
jscs: {
src: [
eslint: {
target: [
'<%= env.nodeTests%>',
'<%= env.browserTests %>',
'test/browser/setup.js',
'test/browser/integration/*.js',
'Gruntfile.js',
'src/*.js',
'lib/*.js',
@@ -63,34 +67,6 @@ module.exports = function(grunt) {
'!src/html5shiv.js'
]
},
jshint: {
options: {
jshintrc: true,
ignores: [
'src/html5printshiv.js',
'src/html5shiv.js'
]
},
files: [
'Gruntfile.js',
'src/*.js',
'lib/*.js',
'feature-detects/**/*.js'
],
tests: {
options: {
jshintrc: true
},
files: {
src: [
'<%= env.nodeTests%>',
'<%= env.browserTests %>',
'test/browser/setup.js',
'test/browser/integration/*.js'
]
}
}
},
clean: {
dist: [
'dist',
@@ -232,11 +208,9 @@ module.exports = function(grunt) {
grunt.registerTask('build', ['clean', 'generate']);
grunt.registerTask('lint', ['jshint', 'jscs']);
grunt.registerTask('default', ['eslint', 'build']);
grunt.registerTask('default', ['lint', 'build']);
var tests = ['clean', 'lint', 'jade', 'instrument', 'env:coverage', 'nodeTests'];
var tests = ['clean', 'eslint', 'jade', 'instrument', 'env:coverage', 'nodeTests'];
if (process.env.APPVEYOR) {
grunt.registerTask('test', tests);

View File

@@ -28,7 +28,8 @@ define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
var bool = false;
try {
if (bool = !!elem.canPlayType) {
bool = !!elem.canPlayType
if (bool) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"') .replace(/^no$/, '');
bool.mp3 = elem.canPlayType('audio/mpeg; codecs="mp3"') .replace(/^no$/, '');

View File

@@ -16,7 +16,8 @@ define(['Modernizr', 'testAllProps'], function(Modernizr, testAllProps) {
var bool = false;
var test = testAllProps('columnCount');
try {
if (bool = !!test) {
bool = !!test
if (bool) {
bool = new Boolean(bool);
}
} catch (e) {}

View File

@@ -16,5 +16,5 @@
Detects support for CSS Snap Points
*/
define(['Modernizr', 'testAllProps'], function(Modernizr, testAllProps) {
Modernizr.addTest('scrollsnappoints', testAllProps('scrollSnapType'));
Modernizr.addTest('scrollsnappoints', testAllProps('scrollSnapType'));
});

View File

@@ -21,6 +21,7 @@ define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('es5syntax', function() {
var value, obj, stringAccess, getter, setter, reservedWords, zeroWidthChars;
try {
/* eslint no-eval: "off" */
// Property access on strings
stringAccess = eval('"foobar"[3] === "b"');
// Getter in property initializer

View File

@@ -12,7 +12,7 @@ Check if browser implements ECMAScript 6 Arrow Functions per specification.
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('arrow', function() {
try {
/* jshint evil: true */
// eslint-disable-next-line
eval('()=>{}');
} catch (e) {
return false;

View File

@@ -53,6 +53,6 @@ define(['Modernizr', 'docElement', 'createElement', 'testStyles', 'hasEvent'], f
} catch (e) {
supportsOnInput = false;
}
return supportsOnInput;
return supportsOnInput;
});
});

View File

@@ -20,7 +20,7 @@ define(['Modernizr', 'hasEvent', 'prefixed'], function(Modernizr, hasEvent, pref
// github.com/Modernizr/Modernizr/issues/1613
// Test if the browser supports the force touch event progression (see notes link)
if (!hasEvent(prefixed('mouseforcewillbegin', window, false), window)) {
return false;
return false;
}
// Test if the browser provides thresholds defining a "force touch" from a normal touch/click event

View File

@@ -41,7 +41,9 @@ define(['Modernizr', 'createElement', 'docElement', 'getBody', 'test/inputtypes'
}
diff = input.type === 'number' && input.valueAsNumber === 1.1 && input.checkValidity();
root.removeChild(el);
body.fake && root.parentNode.removeChild(root);
if (body.fake) {
root.parentNode.removeChild(root);
}
return diff;
});

View File

@@ -12,5 +12,5 @@
Detects support for the crossOrigin attribute on images, which allow for cross domain images inside of a canvas without tainting it
*/
define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
Modernizr.addTest('imgcrossorigin', 'crossOrigin' in createElement('img'));
Modernizr.addTest('imgcrossorigin', 'crossOrigin' in createElement('img'));
});

View File

@@ -23,7 +23,7 @@ define(['Modernizr', 'domPrefixes', 'hasEvent'], function(Modernizr, domPrefixes
Modernizr.addTest('pointerevents', function() {
// Cannot use `.prefixed()` for events, so test each prefix
var bool = false,
i = domPrefixes.length;
i = domPrefixes.length;
// Don't forget un-prefixed...
bool = Modernizr.hasEvent('pointerdown');

View File

@@ -17,6 +17,7 @@ define(['Modernizr'], function(Modernizr) {
try {
// A number of tools, including uglifyjs and require, break on a raw "`", so
// use an eval to get around that.
// eslint-disable-next-line
eval('``');
supports = true;
} catch (e) {}

View File

@@ -42,7 +42,8 @@ define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
// IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
try {
if (bool = !!elem.canPlayType) {
bool = !!elem.canPlayType
if (bool) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '');

View File

@@ -23,7 +23,7 @@ define(['Modernizr', 'createElement', 'isSVG'], function(Modernizr, createElemen
var supports = false;
var shape;
if (!isSVG) {
if (!isSVG) {
containerDiv.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
shape = containerDiv.firstChild;
if ('style' in shape) {

View File

@@ -13,10 +13,11 @@ define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('websocketsbinary', function() {
var protocol = 'https:' == location.protocol ? 'wss' : 'ws',
protoBin;
protoBin;
if ('WebSocket' in window) {
if (protoBin = 'binaryType' in WebSocket.prototype) {
protoBin = 'binaryType' in WebSocket.prototype
if (protoBin) {
return protoBin;
}
try {

View File

@@ -28,12 +28,12 @@ define(['Modernizr', 'addTest'], function(Modernizr, addTest) {
URL = URL || window.MozURL || window.webkitURL || window.MSURL || window.OURL;
}
var data = 'Modernizr',
blob,
bb,
worker,
url,
timeout,
scriptText = 'this.onmessage=function(e){postMessage(e.data)}';
blob,
bb,
worker,
url,
timeout,
scriptText = 'this.onmessage=function(e){postMessage(e.data)}';
try {
blob = new Blob([scriptText], {type: 'text/javascript'});

View File

@@ -20,7 +20,7 @@ define(['Modernizr', 'addTest'], function(Modernizr, addTest) {
Modernizr.addAsyncTest(function() {
try {
var data = 'Modernizr',
worker = new Worker('data:text/javascript;base64,dGhpcy5vbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7cG9zdE1lc3NhZ2UoZS5kYXRhKX0=');
worker = new Worker('data:text/javascript;base64,dGhpcy5vbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7cG9zdE1lc3NhZ2UoZS5kYXRhKX0=');
worker.onmessage = function(e) {
worker.terminate();

View File

@@ -29,11 +29,11 @@ define(['Modernizr', 'addTest', 'test/blob', 'test/url/bloburls', 'test/workers/
// Proper test if prerequisites are met
try {
var buffer,
scriptText = 'var hello = "world"',
blob = new Blob([scriptText], {type: 'text/javascript'}),
url = URL.createObjectURL(blob),
worker = new Worker(url),
timeout;
scriptText = 'var hello = "world"',
blob = new Blob([scriptText], {type: 'text/javascript'}),
url = URL.createObjectURL(blob),
worker = new Worker(url),
timeout;
// Just in case...
worker.onerror = fail;

View File

@@ -24,9 +24,9 @@ define(['lodash', 'metadata'], function(_, metadata) {
property.replace('-', '_');
return property;
}
})
.filter()
.value();
})
.filter()
.value();
// Config uses amdPaths, but the option's just use their names.
// A few of the values have to be massaged in order to match

View File

@@ -40,19 +40,19 @@ var baseRequireConfig = {
contents = contents.replace(/\}\);\s*?$/, '');
if (!contents.match(/Modernizr\.add(Async)?Test\(/)) {
if (!contents.match(/Modernizr\.add(Async)?Test\(/)) {
// remove last return statement and trailing })
contents = contents.replace(/return.*[^return]*$/, '');
contents = contents.replace(/return.*[^return]*$/, '');
}
} else if ((/require\([^\{]*?\{/).test(contents)) {
contents = contents.replace(/require[^\{]+\{/, '');
contents = contents.replace(/\}\);\s*$/, '');
}
} else if ((/require\([^\{]*?\{/).test(contents)) {
contents = contents.replace(/require[^\{]+\{/, '');
contents = contents.replace(/\}\);\s*$/, '');
contents = contents.replace(/return addTest;/, '');
return contents;
}
contents = contents.replace(/return addTest;/, '');
return contents;
}
};
function build(generate, generateBanner, pkg) {

256
modernizr.js Normal file
View File

@@ -0,0 +1,256 @@
/*!
* modernizr v3.3.1
* Build https://modernizr.com/download?-setclasses-dontmin
*
* Copyright (c)
* Faruk Ates
* Paul Irish
* Alex Sexton
* Ryan Seddon
* Patrick Kettner
* Stu Cox
* Richard Herrera
* MIT License
*/
/*
* Modernizr tests which native CSS3 and HTML5 features are available in the
* current UA and makes the results available to you in two ways: as properties on
* a global `Modernizr` object, and as classes on the `<html>` element. This
* information allows you to progressively enhance your pages with a granular level
* of control over the experience.
*/
;(function(window, document, undefined){
var tests = [];
/**
*
* ModernizrProto is the constructor for Modernizr
*
* @class
* @access public
*/
var ModernizrProto = {
// The current version, dummy
_version: '3.3.1',
// Any settings that don't work as separate modules
// can go in here as configuration.
_config: {
'classPrefix': '',
'enableClasses': true,
'enableJSClass': true,
'usePrefixes': true
},
// Queue of tests
_q: [],
// Stub these for people who are listening
on: function(test, cb) {
// I don't really think people should do this, but we can
// safe guard it a bit.
// -- NOTE:: this gets WAY overridden in src/addTest for actual async tests.
// This is in case people listen to synchronous tests. I would leave it out,
// but the code to *disallow* sync tests in the real version of this
// function is actually larger than this.
var self = this;
setTimeout(function() {
cb(self[test]);
}, 0);
},
addTest: function(name, fn, options) {
tests.push({name: name, fn: fn, options: options});
},
addAsyncTest: function(fn) {
tests.push({name: null, fn: fn});
}
};
// Fake some of Object.create so we can force non test results to be non "own" properties.
var Modernizr = function() {};
Modernizr.prototype = ModernizrProto;
// Leak modernizr globally when you `require` it rather than force it here.
// Overwrite name so constructor name is nicer :D
Modernizr = new Modernizr();
var classes = [];
/**
* is returns a boolean if the typeof an obj is exactly type.
*
* @access private
* @function is
* @param {*} obj - A thing we want to check the type of
* @param {string} type - A string to compare the typeof against
* @returns {boolean}
*/
function is(obj, type) {
return typeof obj === type;
}
;
/**
* Run through all tests and detect their support in the current UA.
*
* @access private
*/
function testRunner() {
var featureNames;
var feature;
var aliasIdx;
var result;
var nameIdx;
var featureName;
var featureNameSplit;
for (var featureIdx in tests) {
if (tests.hasOwnProperty(featureIdx)) {
featureNames = [];
feature = tests[featureIdx];
// run the test, throw the return value into the Modernizr,
// then based on that boolean, define an appropriate className
// and push it into an array of classes we'll join later.
//
// If there is no name, it's an 'async' test that is run,
// but not directly added to the object. That should
// be done with a post-run addTest call.
if (feature.name) {
featureNames.push(feature.name.toLowerCase());
if (feature.options && feature.options.aliases && feature.options.aliases.length) {
// Add all the aliases into the names list
for (aliasIdx = 0; aliasIdx < feature.options.aliases.length; aliasIdx++) {
featureNames.push(feature.options.aliases[aliasIdx].toLowerCase());
}
}
}
// Run the test, or use the raw value if it's not a function
result = is(feature.fn, 'function') ? feature.fn() : feature.fn;
// Set each of the names on the Modernizr object
for (nameIdx = 0; nameIdx < featureNames.length; nameIdx++) {
featureName = featureNames[nameIdx];
// Support dot properties as sub tests. We don't do checking to make sure
// that the implied parent tests have been added. You must call them in
// order (either in the test, or make the parent test a dependency).
//
// Cap it to TWO to make the logic simple and because who needs that kind of subtesting
// hashtag famous last words
featureNameSplit = featureName.split('.');
if (featureNameSplit.length === 1) {
Modernizr[featureNameSplit[0]] = result;
} else {
// cast to a Boolean, if not one already
/* jshint -W053 */
if (Modernizr[featureNameSplit[0]] && !(Modernizr[featureNameSplit[0]] instanceof Boolean)) {
Modernizr[featureNameSplit[0]] = new Boolean(Modernizr[featureNameSplit[0]]);
}
Modernizr[featureNameSplit[0]][featureNameSplit[1]] = result;
}
classes.push((result ? '' : 'no-') + featureNameSplit.join('-'));
}
}
}
}
;
/**
* docElement is a convenience wrapper to grab the root element of the document
*
* @access private
* @returns {HTMLElement|SVGElement} The root element of the document
*/
var docElement = document.documentElement;
/**
* A convenience helper to check if the document we are running in is an SVG document
*
* @access private
* @returns {boolean}
*/
var isSVG = docElement.nodeName.toLowerCase() === 'svg';
/**
* setClasses takes an array of class names and adds them to the root element
*
* @access private
* @function setClasses
* @param {string[]} classes - Array of class names
*/
// Pass in an and array of class names, e.g.:
// ['no-webp', 'borderradius', ...]
function setClasses(classes) {
var className = docElement.className;
var classPrefix = Modernizr._config.classPrefix || '';
if (isSVG) {
className = className.baseVal;
}
// Change `no-js` to `js` (independently of the `enableClasses` option)
// Handle classPrefix on this too
if (Modernizr._config.enableJSClass) {
var reJS = new RegExp('(^|\\s)' + classPrefix + 'no-js(\\s|$)');
className = className.replace(reJS, '$1' + classPrefix + 'js$2');
}
if (Modernizr._config.enableClasses) {
// Add the new classes
className += ' ' + classPrefix + classes.join(' ' + classPrefix);
if (isSVG) {
docElement.className.baseVal = className;
} else {
docElement.className = className;
}
}
}
;
// Run each test
testRunner();
// Remove the "no-js" class if it exists
setClasses(classes);
delete ModernizrProto.addTest;
delete ModernizrProto.addAsyncTest;
// Run the things that are supposed to run after the tests
for (var i = 0; i < Modernizr._q.length; i++) {
Modernizr._q[i]();
}
// Leak Modernizr namespace
window.Modernizr = Modernizr;
;
})(window, document);

View File

@@ -23,11 +23,10 @@
"grunt-contrib-connect": "1.0.2",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-jade": "1.0.0",
"grunt-contrib-jshint": "1.0.0",
"grunt-coveralls": "1.0.1",
"grunt-env": "0.4.4",
"grunt-eslint": "^18.1.0",
"grunt-istanbul": "0.7.0",
"grunt-jscs": "3.0.1",
"grunt-mocha": "0.4.15",
"grunt-mocha-test": "0.12.7",
"grunt-saucelabs": "8.6.3",
@@ -99,7 +98,7 @@
}
],
"greenkeeper": {
"ignore": ["joi"]
"ignore": ["joi", "grunt-eslint"]
},
"license": "MIT"
}

View File

@@ -216,10 +216,10 @@ define(['isSVG'], function(isSVG) {
'h.shivMethods&&(' +
// unroll the `createElement` calls
getElements().join().replace(/[\w\-:]+/g, function(nodeName) {
data.createElem(nodeName);
data.frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
data.createElem(nodeName);
data.frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
');return n}'
)(html5, data.frag);
}
@@ -361,7 +361,7 @@ define(['isSVG'], function(isSVG) {
*/
function addWrappers(ownerDocument) {
var node,
nodes = ownerDocument.getElementsByTagName('*'),
nodes = ownerDocument.getElementsByTagName('*'),
index = nodes.length,
reElements = RegExp('^(?:' + getElements().join('|') + ')$', 'i'),
result = [];
@@ -383,7 +383,7 @@ define(['isSVG'], function(isSVG) {
*/
function createWrapper(element) {
var node,
nodes = element.attributes,
nodes = element.attributes,
index = nodes.length,
wrapper = element.ownerDocument.createElement(shivNamespace + ':' + element.nodeName);
@@ -406,7 +406,7 @@ define(['isSVG'], function(isSVG) {
*/
function shivCssText(cssText) {
var pair,
parts = cssText.split('{'),
parts = cssText.split('{'),
index = parts.length,
reElements = RegExp('(^|[\\s,>+~])(' + getElements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
replacement = '$1' + shivNamespace + '\\:$2';
@@ -441,8 +441,8 @@ define(['isSVG'], function(isSVG) {
*/
function shivPrint(ownerDocument) {
var shivedSheet,
wrappers,
data = getExpandoData(ownerDocument),
wrappers,
data = getExpandoData(ownerDocument),
namespaces = ownerDocument.namespaces,
ownerWindow = ownerDocument.parentWindow;
@@ -466,9 +466,9 @@ define(['isSVG'], function(isSVG) {
removeSheet();
var imports,
length,
sheet,
collection = ownerDocument.styleSheets,
length,
sheet,
collection = ownerDocument.styleSheets,
cssText = [],
index = collection.length,
sheets = Array(index);
@@ -531,7 +531,7 @@ define(['isSVG'], function(isSVG) {
module.exports = html5;
}
}(typeof window !== "undefined" ? window : this, document));
}(typeof window !== 'undefined' ? window : this, document));
}
return html5;

12
src/html5shiv.js vendored
View File

@@ -215,10 +215,10 @@ define(['isSVG'], function(isSVG) {
'h.shivMethods&&(' +
// unroll the `createElement` calls
getElements().join().replace(/[\w\-:]+/g, function(nodeName) {
data.createElem(nodeName);
data.frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
data.createElem(nodeName);
data.frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
');return n}'
)(html5, data.frag);
}
@@ -332,7 +332,7 @@ define(['isSVG'], function(isSVG) {
module.exports = html5;
}
}(typeof window !== "undefined" ? window : this, document));
}(typeof window !== 'undefined' ? window : this, document));
}
return html5;
return html5;
});

View File

@@ -62,6 +62,7 @@ define(['ModernizrProto', 'docElement', 'createElement', 'getBody'], function(Mo
body.parentNode.removeChild(body);
docElement.style.overflow = docOverflow;
// Trigger layout so kinetic scrolling isn't disabled in iOS6+
// eslint-disable-next-line
docElement.offsetHeight;
} else {
div.parentNode.removeChild(div);

View File

@@ -27,7 +27,11 @@ define(['Modernizr', 'docElement', 'isSVG'], function(Modernizr, docElement, isS
if (Modernizr._config.enableClasses) {
// Add the new classes
className += ' ' + classPrefix + classes.join(' ' + classPrefix);
isSVG ? docElement.className.baseVal = className : docElement.className = className;
if (isSVG) {
docElement.className.baseVal = className;
} else {
docElement.className = className;
}
}
}

View File

@@ -8,6 +8,7 @@ define(['is', 'fnBind'], function(is, fnBind) {
* @param {array.<string>} props - An array of properties to test for
* @param {object} obj - An object or Element you want to use to test the parameters again
* @param {boolean|object} elem - An Element to bind the property lookup again. Use `false` to prevent the check
* @returns {false|*} returns false if the prop is unsupported, otherwise the value that is supported
*/
function testDOMProps(props, obj, elem) {
var item;

View File

@@ -12,11 +12,12 @@ define(['ModernizrProto', 'cssomPrefixes', 'is', 'testProps', 'domPrefixes', 'te
* @param {HTMLElement|SVGElement} [elem] - An element used to test the property and value against
* @param {string} [value] - A string of a css value
* @param {boolean} [skipValueTest] - An boolean representing if you want to test if value sticks when set
* @returns {false|string} returns the string version of the property, or false if it is unsupported
*/
function testPropsAll(prop, prefixed, elem, value, skipValueTest) {
var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
// did they call .prefixed('boxSizing') or are we just testing a prop?
if (is(prefixed, 'string') || is(prefixed, 'undefined')) {

View File

@@ -29,21 +29,21 @@ describe('iframe context', function() {
});
it('is able to be loaded in an iframe', function(done) {
iframeWindow.$.getScript('../dist/modernizr-build.js')
.done(function(build, status) {
expect(status).to.equal('success');
expect(iframeWindow.Modernizr).to.not.be(undefined);
done();
})
.fail(function(ajaxResponse, errorType, err) {
if (err && err.message) {
expect(err.message).to.be(undefined);
} else {
expect(errorType).to.be(undefined);
}
done();
});
});
iframeWindow.$.getScript('../dist/modernizr-build.js')
.done(function(build, status) {
expect(status).to.equal('success');
expect(iframeWindow.Modernizr).to.not.be(undefined);
done();
})
.fail(function(ajaxResponse, errorType, err) {
if (err && err.message) {
expect(err.message).to.be(undefined);
} else {
expect(errorType).to.be(undefined);
}
done();
});
});
after(function() {
$iframe.remove();

View File

@@ -76,28 +76,28 @@ describe('addTest', function() {
var fakeDetect = function() {};
it('keeps track of requests', function() {
ModernizrProto.on('fakeDetect', fakeDetect);
expect(ModernizrProto._l.fakeDetect).to.be.an('array');
expect(ModernizrProto._l.fakeDetect[0]).to.be(fakeDetect);
ModernizrProto.on('fakeDetect', fakeDetect);
expect(ModernizrProto._l.fakeDetect).to.be.an('array');
expect(ModernizrProto._l.fakeDetect[0]).to.be(fakeDetect);
});
it('does not recreate the queue with duplicate requests', function() {
ModernizrProto.on('fakeDetect', fakeDetect);
ModernizrProto.on('fakeDetect', fakeDetect);
expect(ModernizrProto._l.fakeDetect.length).to.be(2);
ModernizrProto.on('fakeDetect', fakeDetect);
ModernizrProto.on('fakeDetect', fakeDetect);
expect(ModernizrProto._l.fakeDetect.length).to.be(2);
});
it('triggers results if the detect already ran', function(done) {
Modernizr.fakeDetect = 'fake';
Modernizr._trigger = sinon.spy();
ModernizrProto.on('fakeDetect', fakeDetect);
Modernizr.fakeDetect = 'fake';
Modernizr._trigger = sinon.spy();
ModernizrProto.on('fakeDetect', fakeDetect);
setTimeout(function() {
expect(Modernizr._trigger.calledOnce).to.be(true);
expect(Modernizr._trigger.calledWith('fakeDetect', Modernizr.fakeDetect)).to.be(true);
done();
}, 0);
setTimeout(function() {
expect(Modernizr._trigger.calledOnce).to.be(true);
expect(Modernizr._trigger.calledWith('fakeDetect', Modernizr.fakeDetect)).to.be(true);
done();
}, 0);
});
});

View File

@@ -26,32 +26,32 @@ describe('atRule', function() {
});
});
it('returns undefined when the browser does not support CSSRule', function() {
var ref = window.CSSRule;
window.CSSRule = undefined;
it('returns undefined when the browser does not support CSSRule', function() {
var ref = window.CSSRule;
window.CSSRule = undefined;
expect(atRule('charset')).to.be(undefined);
expect(atRule('charset')).to.be(undefined);
window.CSSRule = ref;
window.CSSRule = ref;
});
if (window.CSSRule) {
it('detects `@rule`s', function() {
expect(atRule('charset')).to.be('@charset');
});
if (window.CSSRule) {
it('detects `@rule`s', function() {
expect(atRule('charset')).to.be('@charset');
});
it('returns false when a property is not given', function() {
expect(atRule()).to.be(false);
});
it('returns false when a property is not given', function() {
expect(atRule()).to.be(false);
});
it('returns false when a property is not found', function() {
expect(atRule('fart')).to.be(false);
});
it('returns false when a property is not found', function() {
expect(atRule('fart')).to.be(false);
});
it('detects prefixed properties', function() {
expect(atRule('fake')).to.be('@-modernizr-fake');
});
}
it('detects prefixed properties', function() {
expect(atRule('fake')).to.be('@-modernizr-fake');
});
}
after(function() {
if (window.CSSRule) {

View File

@@ -1,4 +1,9 @@
describe('cssomPrefixes', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "cssomPrefixes"
}]
*/
var setup = function(done, bool) {
return (function() {
define('ModernizrProto', [], function() {return {_config: {usePrefixes: bool}};});

View File

@@ -1,4 +1,10 @@
describe('domPrefixes', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "domPrefixes"
}]
*/
var req;
var setup = function(done, bool) {

View File

@@ -81,6 +81,7 @@ describe('generate', function() {
var output = generate({});
var stashedRequire = window.require;
window.require = function() {};
// eslint-disable-next-line
expect(function() {eval(output);}).to.not.throwError();
window.require = stashedRequire;
});
@@ -89,6 +90,7 @@ describe('generate', function() {
var output = generate({minify: true});
var stashedRequire = window.require;
window.require = function() {};
// eslint-disable-next-line
expect(function() {eval(output);}).to.not.throwError();
window.require = stashedRequire;
});

View File

@@ -1,4 +1,9 @@
describe('injectElementWithStyles', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "sinon"
}]
*/
var injectElementWithStyles;
var originalBody;
var parentNode;

View File

@@ -1,4 +1,9 @@
describe('load', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "load"
}]
*/
var ModernizrProto;
var cleanup;
var sinon;

View File

@@ -1,4 +1,9 @@
describe('prefixes', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "prefixes"
}]
*/
var setup = function(done, bool) {
return (function() {
define('ModernizrProto', [], function() {return {_config: {usePrefixes: bool}};});

View File

@@ -1,4 +1,9 @@
describe('setClasses', function() {
/*
eslint no-unused-vars: [ "error", {
"varsIgnorePattern": "setClasses"
}]
*/
var setClasses;
var cleanup;
var elm;

View File

@@ -23,12 +23,12 @@ describe('testPropsAll', function() {
define('package', [], function() {return {};});
req(['testDOMProps', 'testProps', 'cleanup', 'sinon'], function(_testDOMProps, _testProps, _cleanup, _sinon) {
testDOMProps = _sinon.spy(_testDOMProps);
testProps = _sinon.spy(_testProps);
cleanup = _cleanup;
testDOMProps = _sinon.spy(_testDOMProps);
testProps = _sinon.spy(_testProps);
cleanup = _cleanup;
done();
});
done();
});
});

View File

@@ -2,7 +2,6 @@ describe('testStyles', function() {
var injectElementWithStyles;
var ModernizrProto;
var cleanup;
var testStyles;
before(function(done) {
@@ -18,7 +17,6 @@ describe('testStyles', function() {
req(['ModernizrProto', 'testStyles', 'injectElementWithStyles', 'cleanup'], function(_ModernizrProto, _testStyles, _injectElementWithStyles, _cleanup) {
injectElementWithStyles = _injectElementWithStyles;
ModernizrProto = _ModernizrProto;
testStyles = _testStyles;
cleanup = _cleanup;
done();
});

View File

@@ -1,4 +1,3 @@
/*jshint: globals __coverage__ */
if (typeof define !== 'function') {
var requirejs = require('requirejs');
}

File diff suppressed because it is too large Load Diff

View File

@@ -42,159 +42,159 @@
var regexes = [
{"pattern":"^(Opera)/(\\d+)\\.(\\d+) \\(Nintendo Wii",
"v1_replacement":null,
"family_replacement":"Wii"},
{"pattern":"(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?)",
"v1_replacement":null,
"family_replacement":"Firefox ($1)"},
{"pattern":"(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?",
"v1_replacement":null,
"family_replacement":"Firefox ($1)"},
{"pattern":"(SeaMonkey|Fennec|Camino)/(\\d+)\\.(\\d+)([ab]?\\d+[a-z]*)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Flock)/(\\d+)\\.(\\d+)(b\\d+?)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Fennec)/(\\d+)\\.(\\d+)(pre)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Navigator)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Netscape"},
{"pattern":"(Navigator)/(\\d+)\\.(\\d+)([ab]\\d+)",
"v1_replacement":null,
"family_replacement":"Netscape"},
{"pattern":"(Netscape6)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Netscape"},
{"pattern":"(MyIBrow)/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"My Internet Browser"},
{"pattern":"(Firefox).*Tablet browser (\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"MicroB"},
{"pattern":"(Opera)/9.80.*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?) \\(Swiftfox\\)",
"v1_replacement":null,
"family_replacement":"Swiftfox"},
{"pattern":"(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)? \\(Swiftfox\\)",
"v1_replacement":null,
"family_replacement":"Swiftfox"},
{"pattern":"(konqueror)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Konqueror"},
{"pattern":"(Edge)/(\\d+)\.(\\d+)",
"v1_replacement":null},
{"pattern":"(Jasmine|ANTGalio|Midori|Fresco|Lobo|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|Iron|Iris)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Bolt|Jasmine|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca)/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(iCab|Lunascape|Opera|Android) (\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(IEMobile) (\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"IE Mobile"},
{"pattern":"(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Firefox)/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*)?",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Obigo|OBIGO)[^\\d]*(\\d+)(?:.(\\d+))?",
"v1_replacement":null,
"family_replacement":"Obigo"},
{"pattern":"(MAXTHON|Maxthon) (\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Maxthon"},
{"pattern":"(Maxthon|MyIE2|Uzbl|Shiira)",
"v1_replacement":"0",
"family_replacement":null},
{"pattern":"(PLAYSTATION) (\\d+)",
"v1_replacement":null,
"family_replacement":"PlayStation"},
{"pattern":"(PlayStation Portable)[^\\d]+(\\d+).(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(BrowseX) \\((\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Opera)/(\\d+)\\.(\\d+).*Opera Mobi",
"v1_replacement":null,
"family_replacement":"Opera Mobile"},
{"pattern":"(POLARIS)/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Polaris"},
{"pattern":"(BonEcho)/(\\d+)\\.(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Bon Echo"},
{"pattern":"(iPhone) OS (\\d+)_(\\d+)(?:_(\\d+))?",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Avant)",
"v1_replacement":"1",
"family_replacement":null},
{"pattern":"(Nokia)[EN]?(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Black[bB]erry)(\\d+)",
"v1_replacement":null,
"family_replacement":"Blackberry"},
{"pattern":"(OmniWeb)/v(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Blazer)/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Palm Blazer"},
{"pattern":"(Pre)/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"Palm Pre"},
{"pattern":"(Links) \\((\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(QtWeb) Internet Browser/(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(Version)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*Safari/",
"v1_replacement":null,
"family_replacement":"Safari"},
{"pattern":"(OLPC)/Update(\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"(OLPC)/Update()\\.(\\d+)",
"v1_replacement":"0",
"family_replacement":null},
{"pattern":"(SamsungSGHi560)",
"v1_replacement":null,
"family_replacement":"Samsung SGHi560"},
{"pattern":"^(SonyEricssonK800i)",
"v1_replacement":null,
"family_replacement":"Sony Ericsson K800i"},
{"pattern":"(Teleca Q7)",
"v1_replacement":null,
"family_replacement":null},
{"pattern":"Trident(.*)rv.(\\d+)\.(\\d+)",
"v1_replacement":null,
"family_replacement":"IE"},
{"pattern":"(MSIE) (\\d+)\\.(\\d+)",
"v1_replacement":null,
"family_replacement":"IE"}
{'pattern':'^(Opera)/(\\d+)\\.(\\d+) \\(Nintendo Wii',
'v1_replacement':null,
'family_replacement':'Wii'},
{'pattern':'(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?)',
'v1_replacement':null,
'family_replacement':'Firefox ($1)'},
{'pattern':'(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?',
'v1_replacement':null,
'family_replacement':'Firefox ($1)'},
{'pattern':'(SeaMonkey|Fennec|Camino)/(\\d+)\\.(\\d+)([ab]?\\d+[a-z]*)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Flock)/(\\d+)\\.(\\d+)(b\\d+?)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Fennec)/(\\d+)\\.(\\d+)(pre)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Navigator)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Netscape'},
{'pattern':'(Navigator)/(\\d+)\\.(\\d+)([ab]\\d+)',
'v1_replacement':null,
'family_replacement':'Netscape'},
{'pattern':'(Netscape6)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Netscape'},
{'pattern':'(MyIBrow)/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'My Internet Browser'},
{'pattern':'(Firefox).*Tablet browser (\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'MicroB'},
{'pattern':'(Opera)/9.80.*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?) \\(Swiftfox\\)',
'v1_replacement':null,
'family_replacement':'Swiftfox'},
{'pattern':'(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)? \\(Swiftfox\\)',
'v1_replacement':null,
'family_replacement':'Swiftfox'},
{'pattern':'(konqueror)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Konqueror'},
{'pattern':'(Edge)/(\\d+)\.(\\d+)',
'v1_replacement':null},
{'pattern':'(Jasmine|ANTGalio|Midori|Fresco|Lobo|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|Iron|Iris)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Bolt|Jasmine|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca)/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(iCab|Lunascape|Opera|Android) (\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(IEMobile) (\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'IE Mobile'},
{'pattern':'(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Firefox)/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*)?',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Obigo|OBIGO)[^\\d]*(\\d+)(?:.(\\d+))?',
'v1_replacement':null,
'family_replacement':'Obigo'},
{'pattern':'(MAXTHON|Maxthon) (\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Maxthon'},
{'pattern':'(Maxthon|MyIE2|Uzbl|Shiira)',
'v1_replacement':'0',
'family_replacement':null},
{'pattern':'(PLAYSTATION) (\\d+)',
'v1_replacement':null,
'family_replacement':'PlayStation'},
{'pattern':'(PlayStation Portable)[^\\d]+(\\d+).(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(BrowseX) \\((\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Opera)/(\\d+)\\.(\\d+).*Opera Mobi',
'v1_replacement':null,
'family_replacement':'Opera Mobile'},
{'pattern':'(POLARIS)/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Polaris'},
{'pattern':'(BonEcho)/(\\d+)\\.(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Bon Echo'},
{'pattern':'(iPhone) OS (\\d+)_(\\d+)(?:_(\\d+))?',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Avant)',
'v1_replacement':'1',
'family_replacement':null},
{'pattern':'(Nokia)[EN]?(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Black[bB]erry)(\\d+)',
'v1_replacement':null,
'family_replacement':'Blackberry'},
{'pattern':'(OmniWeb)/v(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Blazer)/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Palm Blazer'},
{'pattern':'(Pre)/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'Palm Pre'},
{'pattern':'(Links) \\((\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(QtWeb) Internet Browser/(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(Version)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*Safari/',
'v1_replacement':null,
'family_replacement':'Safari'},
{'pattern':'(OLPC)/Update(\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'(OLPC)/Update()\\.(\\d+)',
'v1_replacement':'0',
'family_replacement':null},
{'pattern':'(SamsungSGHi560)',
'v1_replacement':null,
'family_replacement':'Samsung SGHi560'},
{'pattern':'^(SonyEricssonK800i)',
'v1_replacement':null,
'family_replacement':'Sony Ericsson K800i'},
{'pattern':'(Teleca Q7)',
'v1_replacement':null,
'family_replacement':null},
{'pattern':'Trident(.*)rv.(\\d+)\.(\\d+)',
'v1_replacement':null,
'family_replacement':'IE'},
{'pattern':'(MSIE) (\\d+)\\.(\\d+)',
'v1_replacement':null,
'family_replacement':'IE'}
];
var parsers = _.map(regexes, function(obj) {
var regexp = new RegExp(obj.pattern),
famRep = obj.family_replacement,
v1Rep = obj.v1_replacement;
famRep = obj.family_replacement,
v1Rep = obj.v1_replacement;
function parser(ua) {
var m = ua.match(regexp);

View File

@@ -71,6 +71,7 @@ describe('cli/build', function() {
build(config, function(file) {
var parsedConfig = file.match(configRE);
//use eval becuase the minified code creates non valid JSON.
// eslint-disable-next-line
parsedConfig = eval('(' + parsedConfig[1].replace(/'/g, '"') + ')');
expect(parsedConfig.classPrefix).to.be(prefix);
done();

View File

@@ -155,41 +155,41 @@ describe('cli/metadata', function() {
describe('returns an array of valid objects', function() {
var schema = Joi.object().keys({
amdPath: Joi.string().required(),
name: Joi.string().required(),
path: Joi.string().required(),
doc: Joi.alternatives().try(Joi.string(), null),
amdPath: Joi.string().required(),
name: Joi.string().required(),
path: Joi.string().required(),
doc: Joi.alternatives().try(Joi.string(), null),
caniuse: Joi.alternatives().try(Joi.string(), null),
caniuse: Joi.alternatives().try(Joi.string(), null),
async: Joi.boolean(),
async: Joi.boolean(),
aliases: Joi.array().items(Joi.string()),
builderAliases: Joi.array().items(Joi.string()),
knownBugs: Joi.array().items(Joi.string()),
warnings: Joi.array().items(Joi.string()),
authors: Joi.array().items(Joi.string()),
tags: Joi.array().items(Joi.string()),
deps: Joi.array().items(Joi.string()),
aliases: Joi.array().items(Joi.string()),
builderAliases: Joi.array().items(Joi.string()),
knownBugs: Joi.array().items(Joi.string()),
warnings: Joi.array().items(Joi.string()),
authors: Joi.array().items(Joi.string()),
tags: Joi.array().items(Joi.string()),
deps: Joi.array().items(Joi.string()),
notes: Joi.array().items(
notes: Joi.array().items(
Joi.object().keys({
name: Joi.string().required(),
href: Joi.string().required()
})
).unique(),
cssclass: Joi.alternatives().try(
cssclass: Joi.alternatives().try(
Joi.string().lowercase(),
Joi.array().items(Joi.string().lowercase())
).required(),
property: Joi.alternatives().try(
property: Joi.alternatives().try(
Joi.string().lowercase(),
Joi.array().items(Joi.string().lowercase())
).required(),
polyfills: Joi.array().items(
polyfills: Joi.array().items(
Joi.object().keys({
name: Joi.string().required(),
authors: Joi.array().items(Joi.string()),
@@ -198,7 +198,7 @@ describe('cli/metadata', function() {
licenses: Joi.array().items(Joi.string()).required()
})
).unique()
});
});
metadata(function(data) {
data.forEach(function(obj) {

View File

@@ -80,11 +80,11 @@ describe('build-query', function() {
});
it('removes custom tests from the build query', function() {
var query = buildQuery({
'feature-detects': ['css/boxsizing', 'custom/test/path']
});
expect(query).to.be('?-boxsizing-dontmin');
var query = buildQuery({
'feature-detects': ['css/boxsizing', 'custom/test/path']
});
expect(query).to.be('?-boxsizing-dontmin');
});
after(function() {