Skip to content

Commit 1132252

Browse files
committed
Merge pull request DefinitelyTyped#7178 from leonyu/modernizr3
Modernizr 3.2.0
2 parents e0a4010 + f791d1f commit 1132252

File tree

3 files changed

+466
-114
lines changed

3 files changed

+466
-114
lines changed

modernizr/modernizr-tests.ts

+96-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ $(function () {
1919
document.getElementById('#notice').innerHTML = msg;
2020
}
2121

22-
Modernizr.prefixed('boxSizing');
22+
Modernizr.prefixed('boxSizing');
2323
Modernizr.prefixed('requestAnimationFrame', window);
24-
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, document.body);
24+
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, true);
2525
Modernizr.prefixed('requestAnimationFrame', window, false);
2626

2727
Modernizr.mq('only all and (max-width: 400px)');
@@ -30,7 +30,7 @@ $(function () {
3030

3131
Modernizr.addTest('track', () => {
3232
var video = document.createElement('video');
33-
// return typeof video.addTextTrack === 'function'
33+
return typeof video.addTextTrack === 'function'
3434
});
3535

3636
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
@@ -45,10 +45,100 @@ $(function () {
4545

4646
Modernizr.testAllProps('boxSizing');
4747

48-
var elem;
48+
var elem: Element;
4949
Modernizr.hasEvent('gesturestart', elem);
50-
51-
if (!Modernizr.autofocus) {
50+
51+
if (!Modernizr.input.autofocus) {
5252
$("[autofocus]").focus();
5353
}
5454
});
55+
56+
57+
Modernizr.on('flash', function( result ) {
58+
if (result) {
59+
// the browser has flash
60+
} else {
61+
// the browser does not have flash
62+
}
63+
});
64+
65+
Modernizr.addTest('itsTuesday', function() {
66+
var d = new Date();
67+
return d.getDay() === 2;
68+
});
69+
70+
Modernizr.addTest('hasJquery', 'jQuery' in window);
71+
72+
var detects = {
73+
'hasjquery': 'jQuery' in window,
74+
'itstuesday': function() {
75+
var d = new Date();
76+
return d.getDay() === 2;
77+
}
78+
}
79+
Modernizr.addTest(detects);
80+
81+
var keyframes = Modernizr.atRule('@keyframes');
82+
if (keyframes) {
83+
// keyframes are supported
84+
// could be `@-webkit-keyframes` or `@keyframes`
85+
} else {
86+
// keyframes === `false`
87+
}
88+
89+
Modernizr._domPrefixes === [ "Moz", "O", "ms", "Webkit" ];
90+
91+
Modernizr.hasEvent('blur') // true;
92+
93+
Modernizr.hasEvent('devicelight', window) // true;
94+
95+
var query = Modernizr.mq('(min-width: 900px)');
96+
if (query) {
97+
// the browser window is larger than 900px
98+
}
99+
100+
Modernizr.prefixed('boxSizing')
101+
102+
var raf = Modernizr.prefixed('requestAnimationFrame', window);
103+
raf(function() {
104+
});
105+
106+
var rAFProp = Modernizr.prefixed('requestAnimationFrame', window, false);
107+
rAFProp === 'WebkitRequestAnimationFrame' // in older webkit
108+
109+
Modernizr.prefixedCSS('transition') // '-moz-transition' in old Firefox
110+
111+
Modernizr.prefixedCSSValue('background', 'linear-gradient(left, red, red)')
112+
113+
var rule = Modernizr._prefixes.join('transform: rotate(20deg); ');
114+
rule === 'transform: rotate(20deg); webkit-transform: rotate(20deg); moz-transform: rotate(20deg); o-transform: rotate(20deg); ms-transform: rotate(20deg);'
115+
116+
rule = 'display:' + Modernizr._prefixes.join('flex; display:') + 'flex';
117+
rule === 'display:flex; display:-webkit-flex; display:-moz-flex; display:-o-flex; display:-ms-flex; display:flex'
118+
119+
Modernizr.testAllProps('boxSizing') // true
120+
Modernizr.testAllProps('display', 'block') // true
121+
Modernizr.testAllProps('display', 'penguin') // false
122+
Modernizr.testAllProps('shapeOutside', 'content-box', true);
123+
124+
Modernizr.testProp('pointerEvents') // true
125+
Modernizr.testProp('pointerEvents', 'none') // true
126+
Modernizr.testProp('pointerEvents', 'penguin') // false
127+
128+
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', function(elem, rule) {
129+
// elem is the first DOM node in the page (by default #modernizr)
130+
// rule is the first argument you supplied - the CSS rule in string form
131+
Modernizr.addTest('widthworks', elem.style.width === '9px')
132+
});
133+
134+
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
135+
document.getElementById('modernizr').style.width === '1px'; // true
136+
document.getElementById('modernizr2').style.width === '2px'; // true
137+
elem.firstChild === document.getElementById('modernizr2'); // true
138+
}, 1);
139+
140+
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
141+
document.getElementById('modernizr').style.width === '1px'; // true
142+
document.getElementById('modernizr2').style.width === '2px'; // true
143+
elem.firstChild === document.getElementById('modernizr2'); // true
144+
}, 1);

modernizr/modernizr-tests.ts.tscparams

-1
This file was deleted.

0 commit comments

Comments
 (0)