-
Notifications
You must be signed in to change notification settings - Fork 16
/
modernizr.javascript.txt
54 lines (43 loc) · 4.38 KB
/
modernizr.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
MODERNIZR
ALTERNATIVES ==> # - feature.js: less features
# - modernizr (prefer)
PRINCIPLE ==> # - Shim: add an unsupported API feature with plugin
# - Polyfill: JavaScript shim. e.g. add unsupported property by IE
# - Fallback:
# - instead of polyfill, add a simplified version of the feature
# - e.g. several CSS properties after another (ones not understood do not
# crash the engine)
# - only polyfill if important: best UX, but slower
#Modernizr only test features, without doing user-agent sniffing.
VERSION ==> #3.3.1
#Can do custom builds with command line tool. Default build includes html5shiv
#At loadtime:
# - tests each FEATURE
# - adds the following:
<html class="[no-]FEATURE"> #For CSS selectors.
Modernizr.FEATURE[.SUBFEATURE] #BOOL. For JavaScript
Modernizr.on('FEATURE', FUNC(BOOL)) #For JavaScript
FEATURES ==> #Check online doc
Modernizr.addTest("feature", BOOL[()]) #Create own FEATURE
Modernizr.addTest({ feature: BOOL[()] }) #Possible BOOL tests:
# - !!OBJ
# - OBJ && ( VAR in OBJ ) or VAR in createElement("TAG")
# - Modernizr.test[All]Props("cssProp")->BOOL:
# - check CSS prop exists
# - if "All", also check if prefixed version exists
# - Modernizr.hasEvent("EVENT"[, OBJ])->BOOL:
# - can OBJ.addEventListener("EVENT")
# - def OBJ: new <div>
# - Modernizr.atRule('@PROP')->BOOL:
# - can use CSS @PROP
Modernizr.testStyles("CSS", FUNC(ELEM, "CSS") #Creates NUM (def: 1) ELEM <div id="ID"> (def: "modernizr[NUM]"), and appends
[, NUM[, "ID"_ARR]]) #<style>CSS</style>
Modernizr.prefixed("jsOrCssProp"[, OBJ[, VAL]]) #Returns [PREFIX]STR for current browser (can be no PREFIX) (e.g. MozSTR), or
#false if cannot find it.
#If OBJ, look as OBJ property.
#If VAL:
# - false: returns "jsOrCssProp", not OBJ.jsOrCssProp
# - VAL: returns OBJ.jsOrCssProp.bind(VAL)
Modernizr.prefixedCSS[Value](...) #Same for CSS prop/value