popper.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /**
  2. * @fileOverview Kickass library to create and place poppers near their reference elements.
  3. * @version {{version}}
  4. * @license
  5. * Copyright (c) 2016 Federico Zivolo and contributors
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE.
  24. */
  25. //
  26. // Cross module loader
  27. // Supported: Node, AMD, Browser globals
  28. //
  29. ;(function (root, factory) {
  30. if (typeof define === 'function' && define.amd) {
  31. // AMD. Register as an anonymous module.
  32. define(factory);
  33. } else if (typeof module === 'object' && module.exports) {
  34. // Node. Does not work with strict CommonJS, but
  35. // only CommonJS-like environments that support module.exports,
  36. // like Node.
  37. module.exports = factory();
  38. } else {
  39. // Browser globals (root is window)
  40. root.Popper = factory();
  41. }
  42. }(this, function () {
  43. 'use strict';
  44. var root = window;
  45. // default options
  46. var DEFAULTS = {
  47. // placement of the popper
  48. placement: 'bottom',
  49. gpuAcceleration: true,
  50. // shift popper from its origin by the given amount of pixels (can be negative)
  51. offset: 0,
  52. // the element which will act as boundary of the popper
  53. boundariesElement: 'viewport',
  54. // amount of pixel used to define a minimum distance between the boundaries and the popper
  55. boundariesPadding: 5,
  56. // popper will try to prevent overflow following this order,
  57. // by default, then, it could overflow on the left and on top of the boundariesElement
  58. preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
  59. // the behavior used by flip to change the placement of the popper
  60. flipBehavior: 'flip',
  61. arrowElement: '[x-arrow]',
  62. // list of functions used to modify the offsets before they are applied to the popper
  63. modifiers: [ 'shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
  64. modifiersIgnored: [],
  65. forceAbsolute: false
  66. };
  67. /**
  68. * Create a new Popper.js instance
  69. * @constructor Popper
  70. * @param {HTMLElement} reference - The reference element used to position the popper
  71. * @param {HTMLElement|Object} popper
  72. * The HTML element used as popper, or a configuration used to generate the popper.
  73. * @param {String} [popper.tagName='div'] The tag name of the generated popper.
  74. * @param {Array} [popper.classNames=['popper']] Array of classes to apply to the generated popper.
  75. * @param {Array} [popper.attributes] Array of attributes to apply, specify `attr:value` to assign a value to it.
  76. * @param {HTMLElement|String} [popper.parent=window.document.body] The parent element, given as HTMLElement or as query string.
  77. * @param {String} [popper.content=''] The content of the popper, it can be text, html, or node; if it is not text, set `contentType` to `html` or `node`.
  78. * @param {String} [popper.contentType='text'] If `html`, the `content` will be parsed as HTML. If `node`, it will be appended as-is.
  79. * @param {String} [popper.arrowTagName='div'] Same as `popper.tagName` but for the arrow element.
  80. * @param {Array} [popper.arrowClassNames='popper__arrow'] Same as `popper.classNames` but for the arrow element.
  81. * @param {String} [popper.arrowAttributes=['x-arrow']] Same as `popper.attributes` but for the arrow element.
  82. * @param {Object} options
  83. * @param {String} [options.placement=bottom]
  84. * Placement of the popper accepted values: `top(-start, -end), right(-start, -end), bottom(-start, -right),
  85. * left(-start, -end)`
  86. *
  87. * @param {HTMLElement|String} [options.arrowElement='[x-arrow]']
  88. * The DOM Node used as arrow for the popper, or a CSS selector used to get the DOM node. It must be child of
  89. * its parent Popper. Popper.js will apply to the given element the style required to align the arrow with its
  90. * reference element.
  91. * By default, it will look for a child node of the popper with the `x-arrow` attribute.
  92. *
  93. * @param {Boolean} [options.gpuAcceleration=true]
  94. * When this property is set to true, the popper position will be applied using CSS3 translate3d, allowing the
  95. * browser to use the GPU to accelerate the rendering.
  96. * If set to false, the popper will be placed using `top` and `left` properties, not using the GPU.
  97. *
  98. * @param {Number} [options.offset=0]
  99. * Amount of pixels the popper will be shifted (can be negative).
  100. *
  101. * @param {String|Element} [options.boundariesElement='viewport']
  102. * The element which will define the boundaries of the popper position, the popper will never be placed outside
  103. * of the defined boundaries (except if `keepTogether` is enabled)
  104. *
  105. * @param {Number} [options.boundariesPadding=5]
  106. * Additional padding for the boundaries
  107. *
  108. * @param {Array} [options.preventOverflowOrder=['left', 'right', 'top', 'bottom']]
  109. * Order used when Popper.js tries to avoid overflows from the boundaries, they will be checked in order,
  110. * this means that the last ones will never overflow
  111. *
  112. * @param {String|Array} [options.flipBehavior='flip']
  113. * The behavior used by the `flip` modifier to change the placement of the popper when the latter is trying to
  114. * overlap its reference element. Defining `flip` as value, the placement will be flipped on
  115. * its axis (`right - left`, `top - bottom`).
  116. * You can even pass an array of placements (eg: `['right', 'left', 'top']` ) to manually specify
  117. * how alter the placement when a flip is needed. (eg. in the above example, it would first flip from right to left,
  118. * then, if even in its new placement, the popper is overlapping its reference element, it will be moved to top)
  119. *
  120. * @param {Array} [options.modifiers=[ 'shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle']]
  121. * List of functions used to modify the data before they are applied to the popper, add your custom functions
  122. * to this array to edit the offsets and placement.
  123. * The function should reflect the @params and @returns of preventOverflow
  124. *
  125. * @param {Array} [options.modifiersIgnored=[]]
  126. * Put here any built-in modifier name you want to exclude from the modifiers list
  127. * The function should reflect the @params and @returns of preventOverflow
  128. *
  129. * @param {Boolean} [options.removeOnDestroy=false]
  130. * Set to true if you want to automatically remove the popper when you call the `destroy` method.
  131. */
  132. function Popper(reference, popper, options) {
  133. this._reference = reference.jquery ? reference[0] : reference;
  134. this.state = {};
  135. // if the popper variable is a configuration object, parse it to generate an HTMLElement
  136. // generate a default popper if is not defined
  137. var isNotDefined = typeof popper === 'undefined' || popper === null;
  138. var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
  139. if (isNotDefined || isConfig) {
  140. this._popper = this.parse(isConfig ? popper : {});
  141. }
  142. // otherwise, use the given HTMLElement as popper
  143. else {
  144. this._popper = popper.jquery ? popper[0] : popper;
  145. }
  146. // with {} we create a new object with the options inside it
  147. this._options = Object.assign({}, DEFAULTS, options);
  148. // refactoring modifiers' list
  149. this._options.modifiers = this._options.modifiers.map(function(modifier){
  150. // remove ignored modifiers
  151. if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
  152. // set the x-placement attribute before everything else because it could be used to add margins to the popper
  153. // margins needs to be calculated to get the correct popper offsets
  154. if (modifier === 'applyStyle') {
  155. this._popper.setAttribute('x-placement', this._options.placement);
  156. }
  157. // return predefined modifier identified by string or keep the custom one
  158. return this.modifiers[modifier] || modifier;
  159. }.bind(this));
  160. // make sure to apply the popper position before any computation
  161. this.state.position = this._getPosition(this._popper, this._reference);
  162. setStyle(this._popper, { position: this.state.position, top: 0 });
  163. // fire the first update to position the popper in the right place
  164. this.update();
  165. // setup event listeners, they will take care of update the position in specific situations
  166. this._setupEventListeners();
  167. return this;
  168. }
  169. //
  170. // Methods
  171. //
  172. /**
  173. * Destroy the popper
  174. * @method
  175. * @memberof Popper
  176. */
  177. Popper.prototype.destroy = function() {
  178. this._popper.removeAttribute('x-placement');
  179. this._popper.style.left = '';
  180. this._popper.style.position = '';
  181. this._popper.style.top = '';
  182. this._popper.style[getSupportedPropertyName('transform')] = '';
  183. this._removeEventListeners();
  184. // remove the popper if user explicity asked for the deletion on destroy
  185. if (this._options.removeOnDestroy) {
  186. this._popper.remove();
  187. }
  188. return this;
  189. };
  190. /**
  191. * Updates the position of the popper, computing the new offsets and applying the new style
  192. * @method
  193. * @memberof Popper
  194. */
  195. Popper.prototype.update = function() {
  196. var data = { instance: this, styles: {} };
  197. // store placement inside the data object, modifiers will be able to edit `placement` if needed
  198. // and refer to _originalPlacement to know the original value
  199. data.placement = this._options.placement;
  200. data._originalPlacement = this._options.placement;
  201. // compute the popper and reference offsets and put them inside data.offsets
  202. data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
  203. // get boundaries
  204. data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
  205. data = this.runModifiers(data, this._options.modifiers);
  206. if (typeof this.state.updateCallback === 'function') {
  207. this.state.updateCallback(data);
  208. }
  209. };
  210. /**
  211. * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
  212. * @method
  213. * @memberof Popper
  214. * @param {Function} callback
  215. */
  216. Popper.prototype.onCreate = function(callback) {
  217. // the createCallbacks return as first argument the popper instance
  218. callback(this);
  219. return this;
  220. };
  221. /**
  222. * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
  223. * used to style popper and its arrow.
  224. * NOTE: it doesn't get fired on the first call of the `Popper.update()` method inside the `Popper` constructor!
  225. * @method
  226. * @memberof Popper
  227. * @param {Function} callback
  228. */
  229. Popper.prototype.onUpdate = function(callback) {
  230. this.state.updateCallback = callback;
  231. return this;
  232. };
  233. /**
  234. * Helper used to generate poppers from a configuration file
  235. * @method
  236. * @memberof Popper
  237. * @param config {Object} configuration
  238. * @returns {HTMLElement} popper
  239. */
  240. Popper.prototype.parse = function(config) {
  241. var defaultConfig = {
  242. tagName: 'div',
  243. classNames: [ 'popper' ],
  244. attributes: [],
  245. parent: root.document.body,
  246. content: '',
  247. contentType: 'text',
  248. arrowTagName: 'div',
  249. arrowClassNames: [ 'popper__arrow' ],
  250. arrowAttributes: [ 'x-arrow']
  251. };
  252. config = Object.assign({}, defaultConfig, config);
  253. var d = root.document;
  254. var popper = d.createElement(config.tagName);
  255. addClassNames(popper, config.classNames);
  256. addAttributes(popper, config.attributes);
  257. if (config.contentType === 'node') {
  258. popper.appendChild(config.content.jquery ? config.content[0] : config.content);
  259. }else if (config.contentType === 'html') {
  260. popper.innerHTML = config.content;
  261. } else {
  262. popper.textContent = config.content;
  263. }
  264. if (config.arrowTagName) {
  265. var arrow = d.createElement(config.arrowTagName);
  266. addClassNames(arrow, config.arrowClassNames);
  267. addAttributes(arrow, config.arrowAttributes);
  268. popper.appendChild(arrow);
  269. }
  270. var parent = config.parent.jquery ? config.parent[0] : config.parent;
  271. // if the given parent is a string, use it to match an element
  272. // if more than one element is matched, the first one will be used as parent
  273. // if no elements are matched, the script will throw an error
  274. if (typeof parent === 'string') {
  275. parent = d.querySelectorAll(config.parent);
  276. if (parent.length > 1) {
  277. console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
  278. }
  279. if (parent.length === 0) {
  280. throw 'ERROR: the given `parent` doesn\'t exists!';
  281. }
  282. parent = parent[0];
  283. }
  284. // if the given parent is a DOM nodes list or an array of nodes with more than one element,
  285. // the first one will be used as parent
  286. if (parent.length > 1 && parent instanceof Element === false) {
  287. console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
  288. parent = parent[0];
  289. }
  290. // append the generated popper to its parent
  291. parent.appendChild(popper);
  292. return popper;
  293. /**
  294. * Adds class names to the given element
  295. * @function
  296. * @ignore
  297. * @param {HTMLElement} target
  298. * @param {Array} classes
  299. */
  300. function addClassNames(element, classNames) {
  301. classNames.forEach(function(className) {
  302. element.classList.add(className);
  303. });
  304. }
  305. /**
  306. * Adds attributes to the given element
  307. * @function
  308. * @ignore
  309. * @param {HTMLElement} target
  310. * @param {Array} attributes
  311. * @example
  312. * addAttributes(element, [ 'data-info:foobar' ]);
  313. */
  314. function addAttributes(element, attributes) {
  315. attributes.forEach(function(attribute) {
  316. element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
  317. });
  318. }
  319. };
  320. /**
  321. * Helper used to get the position which will be applied to the popper
  322. * @method
  323. * @memberof Popper
  324. * @param config {HTMLElement} popper element
  325. * @param reference {HTMLElement} reference element
  326. * @returns {String} position
  327. */
  328. Popper.prototype._getPosition = function(popper, reference) {
  329. var container = getOffsetParent(reference);
  330. if (this._options.forceAbsolute) {
  331. return 'absolute';
  332. }
  333. // Decide if the popper will be fixed
  334. // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
  335. var isParentFixed = isFixed(reference, container);
  336. return isParentFixed ? 'fixed' : 'absolute';
  337. };
  338. /**
  339. * Get offsets to the popper
  340. * @method
  341. * @memberof Popper
  342. * @access private
  343. * @param {Element} popper - the popper element
  344. * @param {Element} reference - the reference element (the popper will be relative to this)
  345. * @returns {Object} An object containing the offsets which will be applied to the popper
  346. */
  347. Popper.prototype._getOffsets = function(popper, reference, placement) {
  348. placement = placement.split('-')[0];
  349. var popperOffsets = {};
  350. popperOffsets.position = this.state.position;
  351. var isParentFixed = popperOffsets.position === 'fixed';
  352. //
  353. // Get reference element position
  354. //
  355. var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
  356. //
  357. // Get popper sizes
  358. //
  359. var popperRect = getOuterSizes(popper);
  360. //
  361. // Compute offsets of popper
  362. //
  363. // depending by the popper placement we have to compute its offsets slightly differently
  364. if (['right', 'left'].indexOf(placement) !== -1) {
  365. popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
  366. if (placement === 'left') {
  367. popperOffsets.left = referenceOffsets.left - popperRect.width;
  368. } else {
  369. popperOffsets.left = referenceOffsets.right;
  370. }
  371. } else {
  372. popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
  373. if (placement === 'top') {
  374. popperOffsets.top = referenceOffsets.top - popperRect.height;
  375. } else {
  376. popperOffsets.top = referenceOffsets.bottom;
  377. }
  378. }
  379. // Add width and height to our offsets object
  380. popperOffsets.width = popperRect.width;
  381. popperOffsets.height = popperRect.height;
  382. return {
  383. popper: popperOffsets,
  384. reference: referenceOffsets
  385. };
  386. };
  387. /**
  388. * Setup needed event listeners used to update the popper position
  389. * @method
  390. * @memberof Popper
  391. * @access private
  392. */
  393. Popper.prototype._setupEventListeners = function() {
  394. // NOTE: 1 DOM access here
  395. this.state.updateBound = this.update.bind(this);
  396. root.addEventListener('resize', this.state.updateBound);
  397. // if the boundariesElement is window we don't need to listen for the scroll event
  398. if (this._options.boundariesElement !== 'window') {
  399. var target = getScrollParent(this._reference);
  400. // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
  401. if (target === root.document.body || target === root.document.documentElement) {
  402. target = root;
  403. }
  404. target.addEventListener('scroll', this.state.updateBound);
  405. }
  406. };
  407. /**
  408. * Remove event listeners used to update the popper position
  409. * @method
  410. * @memberof Popper
  411. * @access private
  412. */
  413. Popper.prototype._removeEventListeners = function() {
  414. // NOTE: 1 DOM access here
  415. root.removeEventListener('resize', this.state.updateBound);
  416. if (this._options.boundariesElement !== 'window') {
  417. var target = getScrollParent(this._reference);
  418. // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
  419. if (target === root.document.body || target === root.document.documentElement) {
  420. target = root;
  421. }
  422. target.removeEventListener('scroll', this.state.updateBound);
  423. }
  424. this.state.updateBound = null;
  425. };
  426. /**
  427. * Computed the boundaries limits and return them
  428. * @method
  429. * @memberof Popper
  430. * @access private
  431. * @param {Object} data - Object containing the property "offsets" generated by `_getOffsets`
  432. * @param {Number} padding - Boundaries padding
  433. * @param {Element} boundariesElement - Element used to define the boundaries
  434. * @returns {Object} Coordinates of the boundaries
  435. */
  436. Popper.prototype._getBoundaries = function(data, padding, boundariesElement) {
  437. // NOTE: 1 DOM access here
  438. var boundaries = {};
  439. var width, height;
  440. if (boundariesElement === 'window') {
  441. var body = root.document.body,
  442. html = root.document.documentElement;
  443. height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
  444. width = Math.max( body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth );
  445. boundaries = {
  446. top: 0,
  447. right: width,
  448. bottom: height,
  449. left: 0
  450. };
  451. } else if (boundariesElement === 'viewport') {
  452. var offsetParent = getOffsetParent(this._popper);
  453. var scrollParent = getScrollParent(this._popper);
  454. var offsetParentRect = getOffsetRect(offsetParent);
  455. // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
  456. var getScrollTopValue = function (element) {
  457. return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
  458. }
  459. var getScrollLeftValue = function (element) {
  460. return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
  461. }
  462. // if the popper is fixed we don't have to substract scrolling from the boundaries
  463. var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
  464. var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
  465. boundaries = {
  466. top: 0 - (offsetParentRect.top - scrollTop),
  467. right: root.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
  468. bottom: root.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
  469. left: 0 - (offsetParentRect.left - scrollLeft)
  470. };
  471. } else {
  472. if (getOffsetParent(this._popper) === boundariesElement) {
  473. boundaries = {
  474. top: 0,
  475. left: 0,
  476. right: boundariesElement.clientWidth,
  477. bottom: boundariesElement.clientHeight
  478. };
  479. } else {
  480. boundaries = getOffsetRect(boundariesElement);
  481. }
  482. }
  483. boundaries.left += padding;
  484. boundaries.right -= padding;
  485. boundaries.top = boundaries.top + padding;
  486. boundaries.bottom = boundaries.bottom - padding;
  487. return boundaries;
  488. };
  489. /**
  490. * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
  491. * @method
  492. * @memberof Popper
  493. * @access public
  494. * @param {Object} data
  495. * @param {Array} modifiers
  496. * @param {Function} ends
  497. */
  498. Popper.prototype.runModifiers = function(data, modifiers, ends) {
  499. var modifiersToRun = modifiers.slice();
  500. if (ends !== undefined) {
  501. modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
  502. }
  503. modifiersToRun.forEach(function(modifier) {
  504. if (isFunction(modifier)) {
  505. data = modifier.call(this, data);
  506. }
  507. }.bind(this));
  508. return data;
  509. };
  510. /**
  511. * Helper used to know if the given modifier depends from another one.
  512. * @method
  513. * @memberof Popper
  514. * @param {String} requesting - name of requesting modifier
  515. * @param {String} requested - name of requested modifier
  516. * @returns {Boolean}
  517. */
  518. Popper.prototype.isModifierRequired = function(requesting, requested) {
  519. var index = getArrayKeyIndex(this._options.modifiers, requesting);
  520. return !!this._options.modifiers.slice(0, index).filter(function(modifier) {
  521. return modifier === requested;
  522. }).length;
  523. };
  524. //
  525. // Modifiers
  526. //
  527. /**
  528. * Modifiers list
  529. * @namespace Popper.modifiers
  530. * @memberof Popper
  531. * @type {Object}
  532. */
  533. Popper.prototype.modifiers = {};
  534. /**
  535. * Apply the computed styles to the popper element
  536. * @method
  537. * @memberof Popper.modifiers
  538. * @argument {Object} data - The data object generated by `update` method
  539. * @returns {Object} The same data object
  540. */
  541. Popper.prototype.modifiers.applyStyle = function(data) {
  542. // apply the final offsets to the popper
  543. // NOTE: 1 DOM access here
  544. var styles = {
  545. position: data.offsets.popper.position
  546. };
  547. // round top and left to avoid blurry text
  548. var left = Math.round(data.offsets.popper.left);
  549. var top = Math.round(data.offsets.popper.top);
  550. // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
  551. // we automatically use the supported prefixed version if needed
  552. var prefixedProperty;
  553. if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
  554. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  555. styles.top = 0;
  556. styles.left = 0;
  557. }
  558. // othwerise, we use the standard `left` and `top` properties
  559. else {
  560. styles.left =left;
  561. styles.top = top;
  562. }
  563. // any property present in `data.styles` will be applied to the popper,
  564. // in this way we can make the 3rd party modifiers add custom styles to it
  565. // Be aware, modifiers could override the properties defined in the previous
  566. // lines of this modifier!
  567. Object.assign(styles, data.styles);
  568. setStyle(this._popper, styles);
  569. // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
  570. // NOTE: 1 DOM access here
  571. this._popper.setAttribute('x-placement', data.placement);
  572. // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
  573. if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
  574. setStyle(data.arrowElement, data.offsets.arrow);
  575. }
  576. return data;
  577. };
  578. /**
  579. * Modifier used to shift the popper on the start or end of its reference element side
  580. * @method
  581. * @memberof Popper.modifiers
  582. * @argument {Object} data - The data object generated by `update` method
  583. * @returns {Object} The data object, properly modified
  584. */
  585. Popper.prototype.modifiers.shift = function(data) {
  586. var placement = data.placement;
  587. var basePlacement = placement.split('-')[0];
  588. var shiftVariation = placement.split('-')[1];
  589. // if shift shiftVariation is specified, run the modifier
  590. if (shiftVariation) {
  591. var reference = data.offsets.reference;
  592. var popper = getPopperClientRect(data.offsets.popper);
  593. var shiftOffsets = {
  594. y: {
  595. start: { top: reference.top },
  596. end: { top: reference.top + reference.height - popper.height }
  597. },
  598. x: {
  599. start: { left: reference.left },
  600. end: { left: reference.left + reference.width - popper.width }
  601. }
  602. };
  603. var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
  604. data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
  605. }
  606. return data;
  607. };
  608. /**
  609. * Modifier used to make sure the popper does not overflows from it's boundaries
  610. * @method
  611. * @memberof Popper.modifiers
  612. * @argument {Object} data - The data object generated by `update` method
  613. * @returns {Object} The data object, properly modified
  614. */
  615. Popper.prototype.modifiers.preventOverflow = function(data) {
  616. var order = this._options.preventOverflowOrder;
  617. var popper = getPopperClientRect(data.offsets.popper);
  618. var check = {
  619. left: function() {
  620. var left = popper.left;
  621. if (popper.left < data.boundaries.left) {
  622. left = Math.max(popper.left, data.boundaries.left);
  623. }
  624. return { left: left };
  625. },
  626. right: function() {
  627. var left = popper.left;
  628. if (popper.right > data.boundaries.right) {
  629. left = Math.min(popper.left, data.boundaries.right - popper.width);
  630. }
  631. return { left: left };
  632. },
  633. top: function() {
  634. var top = popper.top;
  635. if (popper.top < data.boundaries.top) {
  636. top = Math.max(popper.top, data.boundaries.top);
  637. }
  638. return { top: top };
  639. },
  640. bottom: function() {
  641. var top = popper.top;
  642. if (popper.bottom > data.boundaries.bottom) {
  643. top = Math.min(popper.top, data.boundaries.bottom - popper.height);
  644. }
  645. return { top: top };
  646. }
  647. };
  648. order.forEach(function(direction) {
  649. data.offsets.popper = Object.assign(popper, check[direction]());
  650. });
  651. return data;
  652. };
  653. /**
  654. * Modifier used to make sure the popper is always near its reference
  655. * @method
  656. * @memberof Popper.modifiers
  657. * @argument {Object} data - The data object generated by _update method
  658. * @returns {Object} The data object, properly modified
  659. */
  660. Popper.prototype.modifiers.keepTogether = function(data) {
  661. var popper = getPopperClientRect(data.offsets.popper);
  662. var reference = data.offsets.reference;
  663. var f = Math.floor;
  664. if (popper.right < f(reference.left)) {
  665. data.offsets.popper.left = f(reference.left) - popper.width;
  666. }
  667. if (popper.left > f(reference.right)) {
  668. data.offsets.popper.left = f(reference.right);
  669. }
  670. if (popper.bottom < f(reference.top)) {
  671. data.offsets.popper.top = f(reference.top) - popper.height;
  672. }
  673. if (popper.top > f(reference.bottom)) {
  674. data.offsets.popper.top = f(reference.bottom);
  675. }
  676. return data;
  677. };
  678. /**
  679. * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
  680. * Requires the `preventOverflow` modifier before it in order to work.
  681. * **NOTE:** This modifier will run all its previous modifiers everytime it tries to flip the popper!
  682. * @method
  683. * @memberof Popper.modifiers
  684. * @argument {Object} data - The data object generated by _update method
  685. * @returns {Object} The data object, properly modified
  686. */
  687. Popper.prototype.modifiers.flip = function(data) {
  688. // check if preventOverflow is in the list of modifiers before the flip modifier.
  689. // otherwise flip would not work as expected.
  690. if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
  691. console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
  692. return data;
  693. }
  694. if (data.flipped && data.placement === data._originalPlacement) {
  695. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  696. return data;
  697. }
  698. var placement = data.placement.split('-')[0];
  699. var placementOpposite = getOppositePlacement(placement);
  700. var variation = data.placement.split('-')[1] || '';
  701. var flipOrder = [];
  702. if(this._options.flipBehavior === 'flip') {
  703. flipOrder = [
  704. placement,
  705. placementOpposite
  706. ];
  707. } else {
  708. flipOrder = this._options.flipBehavior;
  709. }
  710. flipOrder.forEach(function(step, index) {
  711. if (placement !== step || flipOrder.length === index + 1) {
  712. return;
  713. }
  714. placement = data.placement.split('-')[0];
  715. placementOpposite = getOppositePlacement(placement);
  716. var popperOffsets = getPopperClientRect(data.offsets.popper);
  717. // this boolean is used to distinguish right and bottom from top and left
  718. // they need different computations to get flipped
  719. var a = ['right', 'bottom'].indexOf(placement) !== -1;
  720. // using Math.floor because the reference offsets may contain decimals we are not going to consider here
  721. if (
  722. a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) ||
  723. !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])
  724. ) {
  725. // we'll use this boolean to detect any flip loop
  726. data.flipped = true;
  727. data.placement = flipOrder[index + 1];
  728. if (variation) {
  729. data.placement += '-' + variation;
  730. }
  731. data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
  732. data = this.runModifiers(data, this._options.modifiers, this._flip);
  733. }
  734. }.bind(this));
  735. return data;
  736. };
  737. /**
  738. * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
  739. * The offsets will shift the popper on the side of its reference element.
  740. * @method
  741. * @memberof Popper.modifiers
  742. * @argument {Object} data - The data object generated by _update method
  743. * @returns {Object} The data object, properly modified
  744. */
  745. Popper.prototype.modifiers.offset = function(data) {
  746. var offset = this._options.offset;
  747. var popper = data.offsets.popper;
  748. if (data.placement.indexOf('left') !== -1) {
  749. popper.top -= offset;
  750. }
  751. else if (data.placement.indexOf('right') !== -1) {
  752. popper.top += offset;
  753. }
  754. else if (data.placement.indexOf('top') !== -1) {
  755. popper.left -= offset;
  756. }
  757. else if (data.placement.indexOf('bottom') !== -1) {
  758. popper.left += offset;
  759. }
  760. return data;
  761. };
  762. /**
  763. * Modifier used to move the arrows on the edge of the popper to make sure them are always between the popper and the reference element
  764. * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
  765. * @method
  766. * @memberof Popper.modifiers
  767. * @argument {Object} data - The data object generated by _update method
  768. * @returns {Object} The data object, properly modified
  769. */
  770. Popper.prototype.modifiers.arrow = function(data) {
  771. var arrow = this._options.arrowElement;
  772. // if the arrowElement is a string, suppose it's a CSS selector
  773. if (typeof arrow === 'string') {
  774. arrow = this._popper.querySelector(arrow);
  775. }
  776. // if arrow element is not found, don't run the modifier
  777. if (!arrow) {
  778. return data;
  779. }
  780. // the arrow element must be child of its popper
  781. if (!this._popper.contains(arrow)) {
  782. console.warn('WARNING: `arrowElement` must be child of its popper element!');
  783. return data;
  784. }
  785. // arrow depends on keepTogether in order to work
  786. if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
  787. console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
  788. return data;
  789. }
  790. var arrowStyle = {};
  791. var placement = data.placement.split('-')[0];
  792. var popper = getPopperClientRect(data.offsets.popper);
  793. var reference = data.offsets.reference;
  794. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  795. var len = isVertical ? 'height' : 'width';
  796. var side = isVertical ? 'top' : 'left';
  797. var altSide = isVertical ? 'left' : 'top';
  798. var opSide = isVertical ? 'bottom' : 'right';
  799. var arrowSize = getOuterSizes(arrow)[len];
  800. //
  801. // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
  802. //
  803. // top/left side
  804. if (reference[opSide] - arrowSize < popper[side]) {
  805. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
  806. }
  807. // bottom/right side
  808. if (reference[side] + arrowSize > popper[opSide]) {
  809. data.offsets.popper[side] += (reference[side] + arrowSize) - popper[opSide];
  810. }
  811. // compute center of the popper
  812. var center = reference[side] + (reference[len] / 2) - (arrowSize / 2);
  813. var sideValue = center - popper[side];
  814. // prevent arrow from being placed not contiguously to its popper
  815. sideValue = Math.max(Math.min(popper[len] - arrowSize, sideValue), 0);
  816. arrowStyle[side] = sideValue;
  817. arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
  818. data.offsets.arrow = arrowStyle;
  819. data.arrowElement = arrow;
  820. return data;
  821. };
  822. //
  823. // Helpers
  824. //
  825. /**
  826. * Get the outer sizes of the given element (offset size + margins)
  827. * @function
  828. * @ignore
  829. * @argument {Element} element
  830. * @returns {Object} object containing width and height properties
  831. */
  832. function getOuterSizes(element) {
  833. // NOTE: 1 DOM access here
  834. var _display = element.style.display, _visibility = element.style.visibility;
  835. element.style.display = 'block'; element.style.visibility = 'hidden';
  836. var calcWidthToForceRepaint = element.offsetWidth;
  837. // original method
  838. var styles = root.getComputedStyle(element);
  839. var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
  840. var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
  841. var result = { width: element.offsetWidth + y, height: element.offsetHeight + x };
  842. // reset element styles
  843. element.style.display = _display; element.style.visibility = _visibility;
  844. return result;
  845. }
  846. /**
  847. * Get the opposite placement of the given one/
  848. * @function
  849. * @ignore
  850. * @argument {String} placement
  851. * @returns {String} flipped placement
  852. */
  853. function getOppositePlacement(placement) {
  854. var hash = {left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  855. return placement.replace(/left|right|bottom|top/g, function(matched){
  856. return hash[matched];
  857. });
  858. }
  859. /**
  860. * Given the popper offsets, generate an output similar to getBoundingClientRect
  861. * @function
  862. * @ignore
  863. * @argument {Object} popperOffsets
  864. * @returns {Object} ClientRect like output
  865. */
  866. function getPopperClientRect(popperOffsets) {
  867. var offsets = Object.assign({}, popperOffsets);
  868. offsets.right = offsets.left + offsets.width;
  869. offsets.bottom = offsets.top + offsets.height;
  870. return offsets;
  871. }
  872. /**
  873. * Given an array and the key to find, returns its index
  874. * @function
  875. * @ignore
  876. * @argument {Array} arr
  877. * @argument keyToFind
  878. * @returns index or null
  879. */
  880. function getArrayKeyIndex(arr, keyToFind) {
  881. var i = 0, key;
  882. for (key in arr) {
  883. if (arr[key] === keyToFind) {
  884. return i;
  885. }
  886. i++;
  887. }
  888. return null;
  889. }
  890. /**
  891. * Get CSS computed property of the given element
  892. * @function
  893. * @ignore
  894. * @argument {Eement} element
  895. * @argument {String} property
  896. */
  897. function getStyleComputedProperty(element, property) {
  898. // NOTE: 1 DOM access here
  899. var css = root.getComputedStyle(element, null);
  900. return css[property];
  901. }
  902. /**
  903. * Returns the offset parent of the given element
  904. * @function
  905. * @ignore
  906. * @argument {Element} element
  907. * @returns {Element} offset parent
  908. */
  909. function getOffsetParent(element) {
  910. // NOTE: 1 DOM access here
  911. var offsetParent = element.offsetParent;
  912. return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
  913. }
  914. /**
  915. * Returns the scrolling parent of the given element
  916. * @function
  917. * @ignore
  918. * @argument {Element} element
  919. * @returns {Element} offset parent
  920. */
  921. function getScrollParent(element) {
  922. var parent = element.parentNode;
  923. if (!parent) {
  924. return element;
  925. }
  926. if (parent === root.document) {
  927. // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
  928. // greater than 0 and return the proper element
  929. if (root.document.body.scrollTop) {
  930. return root.document.body;
  931. } else {
  932. return root.document.documentElement;
  933. }
  934. }
  935. // Firefox want us to check `-x` and `-y` variations as well
  936. if (
  937. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 ||
  938. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 ||
  939. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1
  940. ) {
  941. // If the detected scrollParent is body, we perform an additional check on its parentNode
  942. // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
  943. // fixes issue #65
  944. return parent;
  945. }
  946. return getScrollParent(element.parentNode);
  947. }
  948. /**
  949. * Check if the given element is fixed or is inside a fixed parent
  950. * @function
  951. * @ignore
  952. * @argument {Element} element
  953. * @argument {Element} customContainer
  954. * @returns {Boolean} answer to "isFixed?"
  955. */
  956. function isFixed(element) {
  957. if (element === root.document.body) {
  958. return false;
  959. }
  960. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  961. return true;
  962. }
  963. return element.parentNode ? isFixed(element.parentNode) : element;
  964. }
  965. /**
  966. * Set the style to the given popper
  967. * @function
  968. * @ignore
  969. * @argument {Element} element - Element to apply the style to
  970. * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
  971. */
  972. function setStyle(element, styles) {
  973. function is_numeric(n) {
  974. return (n !== '' && !isNaN(parseFloat(n)) && isFinite(n));
  975. }
  976. Object.keys(styles).forEach(function(prop) {
  977. var unit = '';
  978. // add unit if the value is numeric and is one of the following
  979. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
  980. unit = 'px';
  981. }
  982. element.style[prop] = styles[prop] + unit;
  983. });
  984. }
  985. /**
  986. * Check if the given variable is a function
  987. * @function
  988. * @ignore
  989. * @argument {*} functionToCheck - variable to check
  990. * @returns {Boolean} answer to: is a function?
  991. */
  992. function isFunction(functionToCheck) {
  993. var getType = {};
  994. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  995. }
  996. /**
  997. * Get the position of the given element, relative to its offset parent
  998. * @function
  999. * @ignore
  1000. * @param {Element} element
  1001. * @return {Object} position - Coordinates of the element and its `scrollTop`
  1002. */
  1003. function getOffsetRect(element) {
  1004. var elementRect = {
  1005. width: element.offsetWidth,
  1006. height: element.offsetHeight,
  1007. left: element.offsetLeft,
  1008. top: element.offsetTop
  1009. };
  1010. elementRect.right = elementRect.left + elementRect.width;
  1011. elementRect.bottom = elementRect.top + elementRect.height;
  1012. // position
  1013. return elementRect;
  1014. }
  1015. /**
  1016. * Get bounding client rect of given element
  1017. * @function
  1018. * @ignore
  1019. * @param {HTMLElement} element
  1020. * @return {Object} client rect
  1021. */
  1022. function getBoundingClientRect(element) {
  1023. var rect = element.getBoundingClientRect();
  1024. // whether the IE version is lower than 11
  1025. var isIE = navigator.userAgent.indexOf("MSIE") != -1;
  1026. // fix ie document bounding top always 0 bug
  1027. var rectTop = isIE && element.tagName === 'HTML'
  1028. ? -element.scrollTop
  1029. : rect.top;
  1030. return {
  1031. left: rect.left,
  1032. top: rectTop,
  1033. right: rect.right,
  1034. bottom: rect.bottom,
  1035. width: rect.right - rect.left,
  1036. height: rect.bottom - rectTop
  1037. };
  1038. }
  1039. /**
  1040. * Given an element and one of its parents, return the offset
  1041. * @function
  1042. * @ignore
  1043. * @param {HTMLElement} element
  1044. * @param {HTMLElement} parent
  1045. * @return {Object} rect
  1046. */
  1047. function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
  1048. var elementRect = getBoundingClientRect(element);
  1049. var parentRect = getBoundingClientRect(parent);
  1050. if (fixed) {
  1051. var scrollParent = getScrollParent(parent);
  1052. parentRect.top += scrollParent.scrollTop;
  1053. parentRect.bottom += scrollParent.scrollTop;
  1054. parentRect.left += scrollParent.scrollLeft;
  1055. parentRect.right += scrollParent.scrollLeft;
  1056. }
  1057. var rect = {
  1058. top: elementRect.top - parentRect.top ,
  1059. left: elementRect.left - parentRect.left ,
  1060. bottom: (elementRect.top - parentRect.top) + elementRect.height,
  1061. right: (elementRect.left - parentRect.left) + elementRect.width,
  1062. width: elementRect.width,
  1063. height: elementRect.height
  1064. };
  1065. return rect;
  1066. }
  1067. /**
  1068. * Get the prefixed supported property name
  1069. * @function
  1070. * @ignore
  1071. * @argument {String} property (camelCase)
  1072. * @returns {String} prefixed property (camelCase)
  1073. */
  1074. function getSupportedPropertyName(property) {
  1075. var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
  1076. for (var i = 0; i < prefixes.length; i++) {
  1077. var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
  1078. if (typeof root.document.body.style[toCheck] !== 'undefined') {
  1079. return toCheck;
  1080. }
  1081. }
  1082. return null;
  1083. }
  1084. /**
  1085. * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
  1086. * objects to a target object. It will return the target object.
  1087. * This polyfill doesn't support symbol properties, since ES5 doesn't have symbols anyway
  1088. * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  1089. * @function
  1090. * @ignore
  1091. */
  1092. if (!Object.assign) {
  1093. Object.defineProperty(Object, 'assign', {
  1094. enumerable: false,
  1095. configurable: true,
  1096. writable: true,
  1097. value: function(target) {
  1098. if (target === undefined || target === null) {
  1099. throw new TypeError('Cannot convert first argument to object');
  1100. }
  1101. var to = Object(target);
  1102. for (var i = 1; i < arguments.length; i++) {
  1103. var nextSource = arguments[i];
  1104. if (nextSource === undefined || nextSource === null) {
  1105. continue;
  1106. }
  1107. nextSource = Object(nextSource);
  1108. var keysArray = Object.keys(nextSource);
  1109. for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
  1110. var nextKey = keysArray[nextIndex];
  1111. var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  1112. if (desc !== undefined && desc.enumerable) {
  1113. to[nextKey] = nextSource[nextKey];
  1114. }
  1115. }
  1116. }
  1117. return to;
  1118. }
  1119. });
  1120. }
  1121. return Popper;
  1122. }));