uikit 3.11.2-dev.31cd2ba38 → 3.11.2-dev.3cbd0b859

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.eslintrc.json +4 -49
  2. package/.prettierignore +14 -0
  3. package/.prettierrc.json +13 -0
  4. package/.webstorm.js +3 -3
  5. package/CHANGELOG.md +7 -11
  6. package/build/.eslintrc.json +1 -3
  7. package/build/build.js +26 -28
  8. package/build/icons.js +7 -11
  9. package/build/less.js +48 -36
  10. package/build/package.json +2 -2
  11. package/build/prefix.js +21 -18
  12. package/build/publishDev.js +6 -8
  13. package/build/release.js +20 -17
  14. package/build/scope.js +21 -11
  15. package/build/scss.js +72 -39
  16. package/build/util.js +71 -62
  17. package/build/wrapper/icons.js +0 -2
  18. package/dist/css/uikit-core-rtl.css +42 -32
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +42 -32
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +42 -32
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +42 -32
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +88 -133
  27. package/dist/js/components/countdown.min.js +1 -1
  28. package/dist/js/components/filter.js +408 -439
  29. package/dist/js/components/filter.min.js +1 -1
  30. package/dist/js/components/lightbox-panel.js +1098 -1316
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1144 -1393
  33. package/dist/js/components/lightbox.min.js +1 -1
  34. package/dist/js/components/notification.js +94 -114
  35. package/dist/js/components/notification.min.js +1 -1
  36. package/dist/js/components/parallax.js +294 -345
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +292 -344
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +722 -852
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +292 -344
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +612 -802
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -620
  47. package/dist/js/components/sortable.min.js +1 -1
  48. package/dist/js/components/tooltip.js +324 -356
  49. package/dist/js/components/tooltip.min.js +1 -1
  50. package/dist/js/components/upload.js +155 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5256 -6574
  53. package/dist/js/uikit-core.min.js +1 -1
  54. package/dist/js/uikit-icons.js +7 -9
  55. package/dist/js/uikit-icons.min.js +1 -1
  56. package/dist/js/uikit.js +8047 -9840
  57. package/dist/js/uikit.min.js +1 -1
  58. package/jsconfig.json +1 -1
  59. package/package.json +64 -60
  60. package/src/js/api/boot.js +25 -32
  61. package/src/js/api/component.js +15 -28
  62. package/src/js/api/global.js +6 -12
  63. package/src/js/api/hooks.js +14 -33
  64. package/src/js/api/instance.js +7 -15
  65. package/src/js/api/state.js +79 -100
  66. package/src/js/components/countdown.js +24 -50
  67. package/src/js/components/filter.js +70 -66
  68. package/src/js/components/index.js +13 -13
  69. package/src/js/components/internal/lightbox-animations.js +14 -25
  70. package/src/js/components/internal/slider-transitioner.js +66 -45
  71. package/src/js/components/internal/slideshow-animations.js +46 -64
  72. package/src/js/components/lightbox-panel.js +107 -105
  73. package/src/js/components/lightbox.js +17 -39
  74. package/src/js/components/notification.js +49 -43
  75. package/src/js/components/parallax.js +16 -30
  76. package/src/js/components/slider-parallax.js +13 -23
  77. package/src/js/components/slider.js +75 -64
  78. package/src/js/components/slideshow-parallax.js +1 -1
  79. package/src/js/components/slideshow.js +8 -13
  80. package/src/js/components/sortable.js +125 -106
  81. package/src/js/components/tooltip.js +41 -31
  82. package/src/js/components/upload.js +52 -63
  83. package/src/js/core/accordion.js +53 -48
  84. package/src/js/core/alert.js +9 -17
  85. package/src/js/core/core.js +74 -53
  86. package/src/js/core/cover.js +11 -15
  87. package/src/js/core/drop.js +106 -92
  88. package/src/js/core/form-custom.js +20 -25
  89. package/src/js/core/gif.js +3 -7
  90. package/src/js/core/grid.js +57 -58
  91. package/src/js/core/height-match.js +16 -29
  92. package/src/js/core/height-viewport.js +28 -35
  93. package/src/js/core/icon.js +38 -50
  94. package/src/js/core/img.js +130 -105
  95. package/src/js/core/index.js +39 -39
  96. package/src/js/core/leader.js +9 -18
  97. package/src/js/core/margin.js +21 -37
  98. package/src/js/core/modal.js +49 -36
  99. package/src/js/core/nav.js +2 -4
  100. package/src/js/core/navbar.js +112 -88
  101. package/src/js/core/offcanvas.js +49 -53
  102. package/src/js/core/overflow-auto.js +13 -17
  103. package/src/js/core/responsive.js +14 -12
  104. package/src/js/core/scroll.js +10 -20
  105. package/src/js/core/scrollspy-nav.js +34 -31
  106. package/src/js/core/scrollspy.js +37 -54
  107. package/src/js/core/sticky.js +130 -91
  108. package/src/js/core/svg.js +60 -79
  109. package/src/js/core/switcher.js +47 -46
  110. package/src/js/core/tab.js +7 -10
  111. package/src/js/core/toggle.js +64 -66
  112. package/src/js/core/video.js +11 -22
  113. package/src/js/mixin/animate.js +19 -20
  114. package/src/js/mixin/class.js +2 -4
  115. package/src/js/mixin/container.js +7 -11
  116. package/src/js/mixin/internal/animate-fade.js +73 -30
  117. package/src/js/mixin/internal/animate-slide.js +58 -41
  118. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  119. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  120. package/src/js/mixin/media.js +5 -10
  121. package/src/js/mixin/modal.js +89 -66
  122. package/src/js/mixin/parallax.js +53 -48
  123. package/src/js/mixin/position.js +26 -20
  124. package/src/js/mixin/slider-autoplay.js +12 -21
  125. package/src/js/mixin/slider-drag.js +64 -65
  126. package/src/js/mixin/slider-nav.js +26 -35
  127. package/src/js/mixin/slider-reactive.js +2 -8
  128. package/src/js/mixin/slider.js +48 -55
  129. package/src/js/mixin/slideshow.js +13 -19
  130. package/src/js/mixin/togglable.js +89 -63
  131. package/src/js/uikit-core.js +2 -4
  132. package/src/js/uikit.js +2 -4
  133. package/src/js/util/ajax.js +20 -39
  134. package/src/js/util/animation.js +77 -75
  135. package/src/js/util/attr.js +17 -21
  136. package/src/js/util/class.js +14 -52
  137. package/src/js/util/dimensions.js +56 -43
  138. package/src/js/util/dom.js +40 -73
  139. package/src/js/util/env.js +7 -12
  140. package/src/js/util/event.js +60 -59
  141. package/src/js/util/fastdom.js +1 -6
  142. package/src/js/util/filter.js +17 -34
  143. package/src/js/util/index.js +0 -1
  144. package/src/js/util/lang.js +81 -121
  145. package/src/js/util/mouse.js +19 -17
  146. package/src/js/util/options.js +33 -47
  147. package/src/js/util/player.js +40 -36
  148. package/src/js/util/position.js +54 -46
  149. package/src/js/util/selector.js +34 -49
  150. package/src/js/util/style.js +36 -46
  151. package/src/js/util/viewport.js +75 -64
  152. package/src/less/components/base.less +0 -5
  153. package/src/less/components/flex.less +0 -9
  154. package/src/less/components/leader.less +0 -1
  155. package/src/less/components/navbar.less +0 -7
  156. package/src/less/components/utility.less +22 -0
  157. package/src/scss/components/base.scss +0 -5
  158. package/src/scss/components/flex.scss +0 -9
  159. package/src/scss/components/form.scss +3 -3
  160. package/src/scss/components/icon.scss +2 -2
  161. package/src/scss/components/leader.scss +0 -1
  162. package/src/scss/components/navbar.scss +0 -7
  163. package/src/scss/components/search.scss +1 -1
  164. package/src/scss/components/utility.scss +22 -0
  165. package/src/scss/variables-theme.scss +6 -6
  166. package/src/scss/variables.scss +6 -6
  167. package/tests/image.html +38 -22
  168. package/tests/js/index.js +114 -85
  169. package/src/js/mixin/flex-bug.js +0 -56
  170. package/src/js/util/promise.js +0 -191
  171. package/tests/images/test.avif +0 -0
  172. package/tests/images/test.webp +0 -0
@@ -1,43 +1,38 @@
1
- import {once} from './event';
2
- import {Promise} from './promise';
3
- import {assign, includes, noop} from './lang';
1
+ import { once } from './event';
2
+ import { includes, noop } from './lang';
4
3
 
5
4
  export function play(el) {
6
-
7
5
  if (isIFrame(el)) {
8
- call(el, {func: 'playVideo', method: 'play'});
6
+ call(el, { func: 'playVideo', method: 'play' });
9
7
  }
10
8
 
11
9
  if (isHTML5(el)) {
12
10
  try {
13
11
  el.play().catch(noop);
14
- } catch (e) {}
12
+ } catch (e) {
13
+ // noop
14
+ }
15
15
  }
16
-
17
16
  }
18
17
 
19
18
  export function pause(el) {
20
-
21
19
  if (isIFrame(el)) {
22
- call(el, {func: 'pauseVideo', method: 'pause'});
20
+ call(el, { func: 'pauseVideo', method: 'pause' });
23
21
  }
24
22
 
25
23
  if (isHTML5(el)) {
26
24
  el.pause();
27
25
  }
28
-
29
26
  }
30
27
 
31
28
  export function mute(el) {
32
-
33
29
  if (isIFrame(el)) {
34
- call(el, {func: 'mute', method: 'setVolume', value: 0});
30
+ call(el, { func: 'mute', method: 'setVolume', value: 0 });
35
31
  }
36
32
 
37
33
  if (isHTML5(el)) {
38
34
  el.muted = true;
39
35
  }
40
-
41
36
  }
42
37
 
43
38
  export function isVideo(el) {
@@ -45,35 +40,39 @@ export function isVideo(el) {
45
40
  }
46
41
 
47
42
  function isHTML5(el) {
48
- return el && el.tagName === 'VIDEO';
43
+ return el?.tagName === 'VIDEO';
49
44
  }
50
45
 
51
46
  function isIFrame(el) {
52
- return el && el.tagName === 'IFRAME' && (isYoutube(el) || isVimeo(el));
47
+ return el?.tagName === 'IFRAME' && (isYoutube(el) || isVimeo(el));
53
48
  }
54
49
 
55
50
  function isYoutube(el) {
56
- return !!el.src.match(/\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/);
51
+ return !!el.src.match(
52
+ /\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/
53
+ );
57
54
  }
58
55
 
59
56
  function isVimeo(el) {
60
57
  return !!el.src.match(/vimeo\.com\/video\/.*/);
61
58
  }
62
59
 
63
- function call(el, cmd) {
64
- enableApi(el).then(() => post(el, cmd));
60
+ async function call(el, cmd) {
61
+ await enableApi(el);
62
+ post(el, cmd);
65
63
  }
66
64
 
67
65
  function post(el, cmd) {
68
66
  try {
69
- el.contentWindow.postMessage(JSON.stringify(assign({event: 'command'}, cmd)), '*');
70
- } catch (e) {}
67
+ el.contentWindow.postMessage(JSON.stringify({ event: 'command', ...cmd }), '*');
68
+ } catch (e) {
69
+ // noop
70
+ }
71
71
  }
72
72
 
73
73
  const stateKey = '_ukPlayer';
74
74
  let counter = 0;
75
75
  function enableApi(el) {
76
-
77
76
  if (el[stateKey]) {
78
77
  return el[stateKey];
79
78
  }
@@ -84,24 +83,29 @@ function enableApi(el) {
84
83
  const id = ++counter;
85
84
  let poller;
86
85
 
87
- return el[stateKey] = new Promise(resolve => {
88
-
89
- youtube && once(el, 'load', () => {
90
- const listener = () => post(el, {event: 'listening', id});
91
- poller = setInterval(listener, 100);
92
- listener();
93
- });
94
-
95
- once(window, 'message', resolve, false, ({data}) => {
86
+ return (el[stateKey] = new Promise((resolve) => {
87
+ youtube &&
88
+ once(el, 'load', () => {
89
+ const listener = () => post(el, { event: 'listening', id });
90
+ poller = setInterval(listener, 100);
91
+ listener();
92
+ });
96
93
 
94
+ once(window, 'message', resolve, false, ({ data }) => {
97
95
  try {
98
96
  data = JSON.parse(data);
99
- return data && (youtube && data.id === id && data.event === 'onReady' || vimeo && Number(data.player_id) === id);
100
- } catch (e) {}
101
-
97
+ return (
98
+ data &&
99
+ ((youtube && data.id === id && data.event === 'onReady') ||
100
+ (vimeo && Number(data.player_id) === id))
101
+ );
102
+ } catch (e) {
103
+ // noop
104
+ }
102
105
  });
103
106
 
104
- el.src = `${el.src}${includes(el.src, '?') ? '&' : '?'}${youtube ? 'enablejsapi=1' : `api=1&player_id=${id}`}`;
105
-
106
- }).then(() => clearInterval(poller));
107
+ el.src = `${el.src}${includes(el.src, '?') ? '&' : '?'}${
108
+ youtube ? 'enablejsapi=1' : `api=1&player_id=${id}`
109
+ }`;
110
+ }).then(() => clearInterval(poller)));
107
111
  }
@@ -1,18 +1,26 @@
1
- import {offset} from './dimensions';
2
- import {each, endsWith, includes, toFloat} from './lang';
3
- import {getViewport, scrollParents} from './viewport';
1
+ import { offset } from './dimensions';
2
+ import { each, endsWith, includes, toFloat } from './lang';
3
+ import { getViewport, scrollParents } from './viewport';
4
4
 
5
5
  const dirs = {
6
6
  width: ['x', 'left', 'right'],
7
- height: ['y', 'top', 'bottom']
7
+ height: ['y', 'top', 'bottom'],
8
8
  };
9
9
 
10
- export function positionAt(element, target, elAttach, targetAttach, elOffset, targetOffset, flip, boundary) {
11
-
10
+ export function positionAt(
11
+ element,
12
+ target,
13
+ elAttach,
14
+ targetAttach,
15
+ elOffset,
16
+ targetOffset,
17
+ flip,
18
+ boundary
19
+ ) {
12
20
  elAttach = getPos(elAttach);
13
21
  targetAttach = getPos(targetAttach);
14
22
 
15
- const flipped = {element: elAttach, target: targetAttach};
23
+ const flipped = { element: elAttach, target: targetAttach };
16
24
 
17
25
  if (!element || !target) {
18
26
  return flipped;
@@ -35,69 +43,71 @@ export function positionAt(element, target, elAttach, targetAttach, elOffset, ta
35
43
  position.top += elOffset['y'];
36
44
 
37
45
  if (flip) {
38
-
39
46
  let boundaries = scrollParents(element).map(getViewport);
40
47
 
41
48
  if (boundary && !includes(boundaries, boundary)) {
42
49
  boundaries.unshift(boundary);
43
50
  }
44
51
 
45
- boundaries = boundaries.map(el => offset(el));
52
+ boundaries = boundaries.map((el) => offset(el));
46
53
 
47
54
  each(dirs, ([dir, align, alignFlip], prop) => {
48
-
49
55
  if (!(flip === true || includes(flip, dir))) {
50
56
  return;
51
57
  }
52
58
 
53
- boundaries.some(boundary => {
54
-
55
- const elemOffset = elAttach[dir] === align
56
- ? -dim[prop]
57
- : elAttach[dir] === alignFlip
59
+ boundaries.some((boundary) => {
60
+ const elemOffset =
61
+ elAttach[dir] === align
62
+ ? -dim[prop]
63
+ : elAttach[dir] === alignFlip
58
64
  ? dim[prop]
59
65
  : 0;
60
66
 
61
- const targetOffset = targetAttach[dir] === align
62
- ? targetDim[prop]
63
- : targetAttach[dir] === alignFlip
67
+ const targetOffset =
68
+ targetAttach[dir] === align
69
+ ? targetDim[prop]
70
+ : targetAttach[dir] === alignFlip
64
71
  ? -targetDim[prop]
65
72
  : 0;
66
73
 
67
- if (position[align] < boundary[align] || position[align] + dim[prop] > boundary[alignFlip]) {
68
-
74
+ if (
75
+ position[align] < boundary[align] ||
76
+ position[align] + dim[prop] > boundary[alignFlip]
77
+ ) {
69
78
  const centerOffset = dim[prop] / 2;
70
- const centerTargetOffset = targetAttach[dir] === 'center' ? -targetDim[prop] / 2 : 0;
71
-
72
- return elAttach[dir] === 'center' && (
73
- apply(centerOffset, centerTargetOffset)
74
- || apply(-centerOffset, -centerTargetOffset)
75
- ) || apply(elemOffset, targetOffset);
76
-
79
+ const centerTargetOffset =
80
+ targetAttach[dir] === 'center' ? -targetDim[prop] / 2 : 0;
81
+
82
+ return (
83
+ (elAttach[dir] === 'center' &&
84
+ (apply(centerOffset, centerTargetOffset) ||
85
+ apply(-centerOffset, -centerTargetOffset))) ||
86
+ apply(elemOffset, targetOffset)
87
+ );
77
88
  }
78
89
 
79
90
  function apply(elemOffset, targetOffset) {
80
-
81
- const newVal = toFloat((position[align] + elemOffset + targetOffset - elOffset[dir] * 2).toFixed(4));
91
+ const newVal = toFloat(
92
+ (position[align] + elemOffset + targetOffset - elOffset[dir] * 2).toFixed(4)
93
+ );
82
94
 
83
95
  if (newVal >= boundary[align] && newVal + dim[prop] <= boundary[alignFlip]) {
84
96
  position[align] = newVal;
85
97
 
86
- ['element', 'target'].forEach(el => {
87
- flipped[el][dir] = !elemOffset
88
- ? flipped[el][dir]
89
- : flipped[el][dir] === dirs[prop][1]
90
- ? dirs[prop][2]
91
- : dirs[prop][1];
92
- });
98
+ for (const el of ['element', 'target']) {
99
+ if (elemOffset) {
100
+ flipped[el][dir] =
101
+ flipped[el][dir] === dirs[prop][1]
102
+ ? dirs[prop][2]
103
+ : dirs[prop][1];
104
+ }
105
+ }
93
106
 
94
107
  return true;
95
108
  }
96
-
97
109
  }
98
-
99
110
  });
100
-
101
111
  });
102
112
  }
103
113
 
@@ -111,13 +121,12 @@ function moveTo(position, attach, dim, factor) {
111
121
  if (attach[dir] === alignFlip) {
112
122
  position[align] += dim[prop] * factor;
113
123
  } else if (attach[dir] === 'center') {
114
- position[align] += dim[prop] * factor / 2;
124
+ position[align] += (dim[prop] * factor) / 2;
115
125
  }
116
126
  });
117
127
  }
118
128
 
119
129
  function getPos(pos) {
120
-
121
130
  const x = /left|center|right/;
122
131
  const y = /top|center|bottom/;
123
132
 
@@ -127,22 +136,21 @@ function getPos(pos) {
127
136
  pos = x.test(pos[0])
128
137
  ? pos.concat('center')
129
138
  : y.test(pos[0])
130
- ? ['center'].concat(pos)
131
- : ['center', 'center'];
139
+ ? ['center'].concat(pos)
140
+ : ['center', 'center'];
132
141
  }
133
142
 
134
143
  return {
135
144
  x: x.test(pos[0]) ? pos[0] : 'center',
136
- y: y.test(pos[1]) ? pos[1] : 'center'
145
+ y: y.test(pos[1]) ? pos[1] : 'center',
137
146
  };
138
147
  }
139
148
 
140
149
  function getOffsets(offsets, width, height) {
141
-
142
150
  const [x, y] = (offsets || '').split(' ');
143
151
 
144
152
  return {
145
153
  x: x ? toFloat(x) * (endsWith(x, '%') ? width / 100 : 1) : 0,
146
- y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0
154
+ y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0,
147
155
  };
148
156
  }
@@ -1,7 +1,6 @@
1
- import {attr} from './attr';
2
- import {inBrowser} from './env';
3
- import {closest, index, matches, parent} from './filter';
4
- import {isDocument, isString, memoize, toNode, toNodes} from './lang';
1
+ import { attr } from './attr';
2
+ import { closest, index, matches, parent } from './filter';
3
+ import { isDocument, isString, memoize, toNode, toNodes } from './lang';
5
4
 
6
5
  export function query(selector, context) {
7
6
  return find(selector, getContext(selector, context));
@@ -12,7 +11,7 @@ export function queryAll(selector, context) {
12
11
  }
13
12
 
14
13
  function getContext(selector, context = document) {
15
- return isString(selector) && isContextSelector(selector) || isDocument(context)
14
+ return (isString(selector) && isContextSelector(selector)) || isDocument(context)
16
15
  ? context
17
16
  : context.ownerDocument;
18
17
  }
@@ -26,7 +25,6 @@ export function findAll(selector, context) {
26
25
  }
27
26
 
28
27
  function _query(selector, context = document, queryFn) {
29
-
30
28
  if (!selector || !isString(selector)) {
31
29
  return selector;
32
30
  }
@@ -34,63 +32,51 @@ function _query(selector, context = document, queryFn) {
34
32
  selector = selector.replace(contextSanitizeRe, '$1 *');
35
33
 
36
34
  if (isContextSelector(selector)) {
37
-
38
- selector = splitSelector(selector).map(selector => {
39
-
40
- let ctx = context;
41
-
42
- if (selector[0] === '!') {
43
-
44
- const selectors = selector.substr(1).trim().split(' ');
45
- ctx = closest(parent(context), selectors[0]);
46
- selector = selectors.slice(1).join(' ').trim();
47
-
48
- }
49
-
50
- if (selector[0] === '-') {
51
-
52
- const selectors = selector.substr(1).trim().split(' ');
53
- const prev = (ctx || context).previousElementSibling;
54
- ctx = matches(prev, selector.substr(1)) ? prev : null;
55
- selector = selectors.slice(1).join(' ');
56
-
57
- }
58
-
59
- if (!ctx) {
60
- return null;
61
- }
62
-
63
- return `${domPath(ctx)} ${selector}`;
64
-
65
- }).filter(Boolean).join(',');
35
+ selector = splitSelector(selector)
36
+ .map((selector) => {
37
+ let ctx = context;
38
+
39
+ if (selector[0] === '!') {
40
+ const selectors = selector.substr(1).trim().split(' ');
41
+ ctx = closest(parent(context), selectors[0]);
42
+ selector = selectors.slice(1).join(' ').trim();
43
+ }
44
+
45
+ if (selector[0] === '-') {
46
+ const selectors = selector.substr(1).trim().split(' ');
47
+ const prev = (ctx || context).previousElementSibling;
48
+ ctx = matches(prev, selector.substr(1)) ? prev : null;
49
+ selector = selectors.slice(1).join(' ');
50
+ }
51
+
52
+ if (!ctx) {
53
+ return null;
54
+ }
55
+
56
+ return `${domPath(ctx)} ${selector}`;
57
+ })
58
+ .filter(Boolean)
59
+ .join(',');
66
60
 
67
61
  context = document;
68
-
69
62
  }
70
63
 
71
64
  try {
72
-
73
65
  return context[queryFn](selector);
74
-
75
66
  } catch (e) {
76
-
77
67
  return null;
78
-
79
68
  }
80
-
81
69
  }
82
70
 
83
71
  const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
84
72
  const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
85
73
 
86
- const isContextSelector = memoize(selector => selector.match(contextSelectorRe));
74
+ const isContextSelector = memoize((selector) => selector.match(contextSelectorRe));
87
75
 
88
76
  const selectorRe = /.*?[^\\](?:,|$)/g;
89
77
 
90
- const splitSelector = memoize(selector =>
91
- selector.match(selectorRe).map(selector =>
92
- selector.replace(/,$/, '').trim()
93
- )
78
+ const splitSelector = memoize((selector) =>
79
+ selector.match(selectorRe).map((selector) => selector.replace(/,$/, '').trim())
94
80
  );
95
81
 
96
82
  function domPath(element) {
@@ -101,7 +87,7 @@ function domPath(element) {
101
87
  names.unshift(`#${escape(id)}`);
102
88
  break;
103
89
  } else {
104
- let {tagName} = element;
90
+ let { tagName } = element;
105
91
  if (tagName !== 'HTML') {
106
92
  tagName += `:nth-child(${index(element) + 1})`;
107
93
  }
@@ -112,7 +98,6 @@ function domPath(element) {
112
98
  return names.join(' > ');
113
99
  }
114
100
 
115
- const escapeFn = inBrowser && window.CSS && CSS.escape || function (css) { return css.replace(/([^\x7f-\uFFFF\w-])/g, match => `\\${match}`); };
116
101
  export function escape(css) {
117
- return isString(css) ? escapeFn.call(null, css) : '';
102
+ return isString(css) ? CSS.escape(css) : '';
118
103
  }
@@ -1,7 +1,16 @@
1
- import {isIE} from './env';
2
- import {append, fragment, remove} from './dom';
3
- import {addClass} from './class';
4
- import {each, hyphenate, isArray, isNumber, isNumeric, isObject, isString, isUndefined, memoize, toNodes, toWindow} from './lang';
1
+ import {
2
+ each,
3
+ hyphenate,
4
+ isArray,
5
+ isNumber,
6
+ isNumeric,
7
+ isObject,
8
+ isString,
9
+ isUndefined,
10
+ memoize,
11
+ toNodes,
12
+ toWindow,
13
+ } from './lang';
5
14
 
6
15
  const cssNumber = {
7
16
  'animation-iteration-count': true,
@@ -11,22 +20,19 @@ const cssNumber = {
11
20
  'flex-shrink': true,
12
21
  'font-weight': true,
13
22
  'line-height': true,
14
- 'opacity': true,
15
- 'order': true,
16
- 'orphans': true,
23
+ opacity: true,
24
+ order: true,
25
+ orphans: true,
17
26
  'stroke-dasharray': true,
18
27
  'stroke-dashoffset': true,
19
- 'widows': true,
28
+ widows: true,
20
29
  'z-index': true,
21
- 'zoom': true
30
+ zoom: true,
22
31
  };
23
32
 
24
33
  export function css(element, property, value, priority = '') {
25
-
26
- return toNodes(element).map(element => {
27
-
34
+ return toNodes(element).map((element) => {
28
35
  if (isString(property)) {
29
-
30
36
  property = propName(property);
31
37
 
32
38
  if (isUndefined(value)) {
@@ -34,27 +40,26 @@ export function css(element, property, value, priority = '') {
34
40
  } else if (!value && !isNumber(value)) {
35
41
  element.style.removeProperty(property);
36
42
  } else {
37
- element.style.setProperty(property, isNumeric(value) && !cssNumber[property] ? `${value}px` : value, priority);
43
+ element.style.setProperty(
44
+ property,
45
+ isNumeric(value) && !cssNumber[property] ? `${value}px` : value,
46
+ priority
47
+ );
38
48
  }
39
-
40
49
  } else if (isArray(property)) {
41
-
42
50
  const styles = getStyles(element);
43
-
44
- return property.reduce((props, property) => {
45
- props[property] = styles[propName(property)];
46
- return props;
47
- }, {});
48
-
51
+ const props = {};
52
+ for (const prop of property) {
53
+ props[prop] = styles[propName(prop)];
54
+ }
55
+ return props;
49
56
  } else if (isObject(property)) {
50
57
  priority = value;
51
58
  each(property, (value, property) => css(element, property, value, priority));
52
59
  }
53
60
 
54
61
  return element;
55
-
56
62
  })[0];
57
-
58
63
  }
59
64
 
60
65
  function getStyles(element, pseudoElt) {
@@ -65,44 +70,29 @@ function getStyle(element, property, pseudoElt) {
65
70
  return getStyles(element, pseudoElt)[property];
66
71
  }
67
72
 
68
- const parseCssVar = memoize(name => {
69
- /* usage in css: .uk-name:before { content:"xyz" } */
70
-
71
- const element = append(document.documentElement, fragment('<div>'));
72
-
73
- addClass(element, `uk-${name}`);
74
-
75
- const value = getStyle(element, 'content', ':before');
76
-
77
- remove(element);
78
-
79
- return value;
80
- });
81
-
82
73
  const propertyRe = /^\s*(["'])?(.*?)\1\s*$/;
83
74
  export function getCssVar(name) {
84
- return (isIE
85
- ? parseCssVar(name)
86
- : getStyles(document.documentElement).getPropertyValue(`--uk-${name}`)
87
- ).replace(propertyRe, '$2');
75
+ return getStyles(document.documentElement)
76
+ .getPropertyValue(`--uk-${name}`)
77
+ .replace(propertyRe, '$2');
88
78
  }
89
79
 
90
80
  // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
91
- export const propName = memoize(name => vendorPropName(name));
81
+ export const propName = memoize((name) => vendorPropName(name));
92
82
 
93
83
  const cssPrefixes = ['webkit', 'moz', 'ms'];
94
84
 
95
85
  function vendorPropName(name) {
96
-
97
86
  name = hyphenate(name);
98
87
 
99
- const {style} = document.documentElement;
88
+ const { style } = document.documentElement;
100
89
 
101
90
  if (name in style) {
102
91
  return name;
103
92
  }
104
93
 
105
- let i = cssPrefixes.length, prefixedName;
94
+ let i = cssPrefixes.length,
95
+ prefixedName;
106
96
 
107
97
  while (i--) {
108
98
  prefixedName = `-${cssPrefixes[i]}-${name}`;