popper_js 1.12.5 → 1.12.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8089907f1bf28ae42a35a959a4bcefa2bc043571
4
- data.tar.gz: 0def1728cde6f63ed26694e73dfcaa81bd45f8f1
3
+ metadata.gz: a59bbeb89ea6c4566e4b1f24369a10082c23c97a
4
+ data.tar.gz: b864874a2d2b4119cd99344c177f59411c57035a
5
5
  SHA512:
6
- metadata.gz: 61ebe93278413291f87af3b4a4d110f5ec0f10d5bce531966f2bd78d86ae548ef70759bf2a49fab2373fd2d1bfb78dfeb6e831493738c902490c624b88bb47f7
7
- data.tar.gz: 9d4248e9e31d1c56e7d0c4178b650dfebf78c700df9a2ef154dfba467316643ef2d505406102cc24c461f674ce04f05077c0dd9c0f50966f6bfc4e72deb81e89
6
+ metadata.gz: dda8c512d5397612025f6b4f755a599bd3ecb5ca9a452a6b26d2fa0b66823a5d4dee890fc6527f221cec2182babbbd8925bea946dc038799b916684c24169b82
7
+ data.tar.gz: 60c205e38c0920530c1bd32a56caa40d98bf3a4b51ecec43423f0b1268f1c57b98ed1e5fdcac25318251719ef385542ae59f2fe7745b5f1e404a11f8fd062433
@@ -1,6 +1,6 @@
1
1
  /**!
2
2
  * @fileOverview Kickass library to create and place poppers near their reference elements.
3
- * @version 1.12.5
3
+ * @version 1.12.9
4
4
  * @license
5
5
  * Copyright (c) 2016 Federico Zivolo and contributors
6
6
  *
@@ -28,22 +28,7 @@
28
28
  (global.Popper = factory());
29
29
  }(this, (function () { 'use strict';
30
30
 
31
- var nativeHints = ['native code', '[object MutationObserverConstructor]'];
32
-
33
- /**
34
- * Determine if a function is implemented natively (as opposed to a polyfill).
35
- * @method
36
- * @memberof Popper.Utils
37
- * @argument {Function | undefined} fn the function to check
38
- * @returns {Boolean}
39
- */
40
- var isNative = (function (fn) {
41
- return nativeHints.some(function (hint) {
42
- return (fn || '').toString().indexOf(hint) > -1;
43
- });
44
- });
45
-
46
- var isBrowser = typeof window !== 'undefined';
31
+ var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
47
32
  var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
48
33
  var timeoutDuration = 0;
49
34
  for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
@@ -54,26 +39,16 @@ for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
54
39
  }
55
40
 
56
41
  function microtaskDebounce(fn) {
57
- var scheduled = false;
58
- var i = 0;
59
- var elem = document.createElement('span');
60
-
61
- // MutationObserver provides a mechanism for scheduling microtasks, which
62
- // are scheduled *before* the next task. This gives us a way to debounce
63
- // a function but ensure it's called *before* the next paint.
64
- var observer = new MutationObserver(function () {
65
- fn();
66
- scheduled = false;
67
- });
68
-
69
- observer.observe(elem, { attributes: true });
70
-
42
+ var called = false;
71
43
  return function () {
72
- if (!scheduled) {
73
- scheduled = true;
74
- elem.setAttribute('x-index', i);
75
- i = i + 1; // don't use compund (+=) because it doesn't get optimized in V8
44
+ if (called) {
45
+ return;
76
46
  }
47
+ called = true;
48
+ window.Promise.resolve().then(function () {
49
+ called = false;
50
+ fn();
51
+ });
77
52
  };
78
53
  }
79
54
 
@@ -90,11 +65,7 @@ function taskDebounce(fn) {
90
65
  };
91
66
  }
92
67
 
93
- // It's common for MutationObserver polyfills to be seen in the wild, however
94
- // these rely on Mutation Events which only occur when an element is connected
95
- // to the DOM. The algorithm used in this module does not use a connected element,
96
- // and so we must ensure that a *native* MutationObserver is available.
97
- var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserver);
68
+ var supportsMicroTasks = isBrowser && window.Promise;
98
69
 
99
70
  /**
100
71
  * Create a debounced version of a method, that's asynchronously deferred
@@ -105,7 +76,7 @@ var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserv
105
76
  * @argument {Function} fn
106
77
  * @returns {Function}
107
78
  */
108
- var debounce = supportsNativeMutationObserver ? microtaskDebounce : taskDebounce;
79
+ var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
109
80
 
110
81
  /**
111
82
  * Check if the given variable is a function
@@ -131,7 +102,7 @@ function getStyleComputedProperty(element, property) {
131
102
  return [];
132
103
  }
133
104
  // NOTE: 1 DOM access here
134
- var css = window.getComputedStyle(element, null);
105
+ var css = getComputedStyle(element, null);
135
106
  return property ? css[property] : css;
136
107
  }
137
108
 
@@ -158,8 +129,16 @@ function getParentNode(element) {
158
129
  */
159
130
  function getScrollParent(element) {
160
131
  // Return body, `getScroll` will take care to get the correct `scrollTop` from it
161
- if (!element || ['HTML', 'BODY', '#document'].indexOf(element.nodeName) !== -1) {
162
- return window.document.body;
132
+ if (!element) {
133
+ return document.body;
134
+ }
135
+
136
+ switch (element.nodeName) {
137
+ case 'HTML':
138
+ case 'BODY':
139
+ return element.ownerDocument.body;
140
+ case '#document':
141
+ return element.body;
163
142
  }
164
143
 
165
144
  // Firefox want us to check `-x` and `-y` variations as well
@@ -189,7 +168,11 @@ function getOffsetParent(element) {
189
168
  var nodeName = offsetParent && offsetParent.nodeName;
190
169
 
191
170
  if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
192
- return window.document.documentElement;
171
+ if (element) {
172
+ return element.ownerDocument.documentElement;
173
+ }
174
+
175
+ return document.documentElement;
193
176
  }
194
177
 
195
178
  // .offsetParent will return the closest TD or TABLE in case
@@ -236,7 +219,7 @@ function getRoot(node) {
236
219
  function findCommonOffsetParent(element1, element2) {
237
220
  // This check is needed to avoid errors in case one of the elements isn't defined for any reason
238
221
  if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
239
- return window.document.documentElement;
222
+ return document.documentElement;
240
223
  }
241
224
 
242
225
  // Here we make sure to give as "start" the element that comes first in the DOM
@@ -284,8 +267,8 @@ function getScroll(element) {
284
267
  var nodeName = element.nodeName;
285
268
 
286
269
  if (nodeName === 'BODY' || nodeName === 'HTML') {
287
- var html = window.document.documentElement;
288
- var scrollingElement = window.document.scrollingElement || html;
270
+ var html = element.ownerDocument.documentElement;
271
+ var scrollingElement = element.ownerDocument.scrollingElement || html;
289
272
  return scrollingElement[upperSide];
290
273
  }
291
274
 
@@ -328,7 +311,7 @@ function getBordersSize(styles, axis) {
328
311
  var sideA = axis === 'x' ? 'Left' : 'Top';
329
312
  var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
330
313
 
331
- return +styles['border' + sideA + 'Width'].split('px')[0] + +styles['border' + sideB + 'Width'].split('px')[0];
314
+ return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
332
315
  }
333
316
 
334
317
  /**
@@ -351,9 +334,9 @@ function getSize(axis, body, html, computedStyle) {
351
334
  }
352
335
 
353
336
  function getWindowSizes() {
354
- var body = window.document.body;
355
- var html = window.document.documentElement;
356
- var computedStyle = isIE10$1() && window.getComputedStyle(html);
337
+ var body = document.body;
338
+ var html = document.documentElement;
339
+ var computedStyle = isIE10$1() && getComputedStyle(html);
357
340
 
358
341
  return {
359
342
  height: getSize('Height', body, html, computedStyle),
@@ -496,8 +479,8 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
496
479
  var scrollParent = getScrollParent(children);
497
480
 
498
481
  var styles = getStyleComputedProperty(parent);
499
- var borderTopWidth = +styles.borderTopWidth.split('px')[0];
500
- var borderLeftWidth = +styles.borderLeftWidth.split('px')[0];
482
+ var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
483
+ var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
501
484
 
502
485
  var offsets = getClientRect({
503
486
  top: childrenRect.top - parentRect.top - borderTopWidth,
@@ -513,8 +496,8 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
513
496
  // differently when margins are applied to it. The margins are included in
514
497
  // the box of the documentElement, in the other cases not.
515
498
  if (!isIE10 && isHTML) {
516
- var marginTop = +styles.marginTop.split('px')[0];
517
- var marginLeft = +styles.marginLeft.split('px')[0];
499
+ var marginTop = parseFloat(styles.marginTop, 10);
500
+ var marginLeft = parseFloat(styles.marginLeft, 10);
518
501
 
519
502
  offsets.top -= borderTopWidth - marginTop;
520
503
  offsets.bottom -= borderTopWidth - marginTop;
@@ -534,7 +517,7 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
534
517
  }
535
518
 
536
519
  function getViewportOffsetRectRelativeToArtbitraryNode(element) {
537
- var html = window.document.documentElement;
520
+ var html = element.ownerDocument.documentElement;
538
521
  var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
539
522
  var width = Math.max(html.clientWidth, window.innerWidth || 0);
540
523
  var height = Math.max(html.clientHeight, window.innerHeight || 0);
@@ -593,12 +576,12 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
593
576
  // Handle other cases based on DOM element used as boundaries
594
577
  var boundariesNode = void 0;
595
578
  if (boundariesElement === 'scrollParent') {
596
- boundariesNode = getScrollParent(getParentNode(popper));
579
+ boundariesNode = getScrollParent(getParentNode(reference));
597
580
  if (boundariesNode.nodeName === 'BODY') {
598
- boundariesNode = window.document.documentElement;
581
+ boundariesNode = popper.ownerDocument.documentElement;
599
582
  }
600
583
  } else if (boundariesElement === 'window') {
601
- boundariesNode = window.document.documentElement;
584
+ boundariesNode = popper.ownerDocument.documentElement;
602
585
  } else {
603
586
  boundariesNode = boundariesElement;
604
587
  }
@@ -719,7 +702,7 @@ function getReferenceOffsets(state, popper, reference) {
719
702
  * @returns {Object} object containing width and height properties
720
703
  */
721
704
  function getOuterSizes(element) {
722
- var styles = window.getComputedStyle(element);
705
+ var styles = getComputedStyle(element);
723
706
  var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
724
707
  var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
725
708
  var result = {
@@ -839,10 +822,11 @@ function runModifiers(modifiers, data, ends) {
839
822
  var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
840
823
 
841
824
  modifiersToRun.forEach(function (modifier) {
842
- if (modifier.function) {
825
+ if (modifier['function']) {
826
+ // eslint-disable-line dot-notation
843
827
  console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
844
828
  }
845
- var fn = modifier.function || modifier.fn;
829
+ var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
846
830
  if (modifier.enabled && isFunction(fn)) {
847
831
  // Add properties to offsets to make them a complete clientRect object
848
832
  // we do this before each modifier to make sure the previous one doesn't
@@ -935,7 +919,7 @@ function getSupportedPropertyName(property) {
935
919
  for (var i = 0; i < prefixes.length - 1; i++) {
936
920
  var prefix = prefixes[i];
937
921
  var toCheck = prefix ? '' + prefix + upperProp : property;
938
- if (typeof window.document.body.style[toCheck] !== 'undefined') {
922
+ if (typeof document.body.style[toCheck] !== 'undefined') {
939
923
  return toCheck;
940
924
  }
941
925
  }
@@ -969,9 +953,19 @@ function destroy() {
969
953
  return this;
970
954
  }
971
955
 
956
+ /**
957
+ * Get the window associated with the element
958
+ * @argument {Element} element
959
+ * @returns {Window}
960
+ */
961
+ function getWindow(element) {
962
+ var ownerDocument = element.ownerDocument;
963
+ return ownerDocument ? ownerDocument.defaultView : window;
964
+ }
965
+
972
966
  function attachToScrollParents(scrollParent, event, callback, scrollParents) {
973
967
  var isBody = scrollParent.nodeName === 'BODY';
974
- var target = isBody ? window : scrollParent;
968
+ var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
975
969
  target.addEventListener(event, callback, { passive: true });
976
970
 
977
971
  if (!isBody) {
@@ -989,7 +983,7 @@ function attachToScrollParents(scrollParent, event, callback, scrollParents) {
989
983
  function setupEventListeners(reference, options, state, updateBound) {
990
984
  // Resize event listener on window
991
985
  state.updateBound = updateBound;
992
- window.addEventListener('resize', state.updateBound, { passive: true });
986
+ getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
993
987
 
994
988
  // Scroll event listener on scroll parents
995
989
  var scrollElement = getScrollParent(reference);
@@ -1020,7 +1014,7 @@ function enableEventListeners() {
1020
1014
  */
1021
1015
  function removeEventListeners(reference, state) {
1022
1016
  // Remove resize event listener on window
1023
- window.removeEventListener('resize', state.updateBound);
1017
+ getWindow(reference).removeEventListener('resize', state.updateBound);
1024
1018
 
1025
1019
  // Remove scroll event listener on scroll parents
1026
1020
  state.scrollParents.forEach(function (target) {
@@ -1044,7 +1038,7 @@ function removeEventListeners(reference, state) {
1044
1038
  */
1045
1039
  function disableEventListeners() {
1046
1040
  if (this.state.eventsEnabled) {
1047
- window.cancelAnimationFrame(this.scheduleUpdate);
1041
+ cancelAnimationFrame(this.scheduleUpdate);
1048
1042
  this.state = removeEventListeners(this.reference, this.state);
1049
1043
  }
1050
1044
  }
@@ -1284,6 +1278,8 @@ function isModifierRequired(modifiers, requestingName, requestedName) {
1284
1278
  * @returns {Object} The data object, properly modified
1285
1279
  */
1286
1280
  function arrow(data, options) {
1281
+ var _data$offsets$arrow;
1282
+
1287
1283
  // arrow depends on keepTogether in order to work
1288
1284
  if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
1289
1285
  return data;
@@ -1335,22 +1331,23 @@ function arrow(data, options) {
1335
1331
  if (reference[side] + arrowElementSize > popper[opSide]) {
1336
1332
  data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
1337
1333
  }
1334
+ data.offsets.popper = getClientRect(data.offsets.popper);
1338
1335
 
1339
1336
  // compute center of the popper
1340
1337
  var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
1341
1338
 
1342
1339
  // Compute the sideValue using the updated popper offsets
1343
1340
  // take popper margin in account because we don't have this info available
1344
- var popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');
1345
- var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;
1341
+ var css = getStyleComputedProperty(data.instance.popper);
1342
+ var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
1343
+ var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
1344
+ var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
1346
1345
 
1347
1346
  // prevent arrowElement from being placed not contiguously to its popper
1348
1347
  sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
1349
1348
 
1350
1349
  data.arrowElement = arrowElement;
1351
- data.offsets.arrow = {};
1352
- data.offsets.arrow[side] = Math.round(sideValue);
1353
- data.offsets.arrow[altSide] = ''; // make sure to unset any eventual altSide value from the DOM node
1350
+ data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
1354
1351
 
1355
1352
  return data;
1356
1353
  }
@@ -2322,8 +2319,8 @@ var Popper = function () {
2322
2319
  };
2323
2320
 
2324
2321
  // get reference and popper elements (allow jQuery wrappers)
2325
- this.reference = reference.jquery ? reference[0] : reference;
2326
- this.popper = popper.jquery ? popper[0] : popper;
2322
+ this.reference = reference && reference.jquery ? reference[0] : reference;
2323
+ this.popper = popper && popper.jquery ? popper[0] : popper;
2327
2324
 
2328
2325
  // Deep merge modifiers options
2329
2326
  this.options.modifiers = {};
@@ -1,4 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'popper_js/version'
4
- require 'popper_js/engine' if defined?(Rails)
4
+
5
+ if defined?(::Rails)
6
+ require 'popper_js/engine'
7
+ else
8
+ gem_path = File.expand_path('..', File.dirname(__FILE__))
9
+ assets_path = File.join(gem_path, 'assets')
10
+ if defined?(::Sprockets)
11
+ Sprockets.append_path(File.join(assets_path, 'javascripts'))
12
+ elsif defined?(::Hanami)
13
+ Hanami::Assets.sources << assets_path
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PopperJs
4
- VERSION = '1.12.5'
4
+ VERSION = '1.12.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popper_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.5
4
+ version: 1.12.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-21 00:00:00.000000000 Z
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler