@gitlab/ui 137.2.4 → 137.2.5

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.
@@ -338,14 +338,10 @@ var script = {
338
338
  },
339
339
  handleAutoClose(e) {
340
340
  var _this$$refs$baseDropd, _this$$refs$baseDropd2;
341
- if (this.autoClose && e.target.closest(ITEM_SELECTOR) && // The optional chaining here is to accommodate specs that use shallow mounting.
342
- // Ideally, those specs would either:
343
- // - stub out the `BaseDropdown` component to include a stub `containsElement` method, or
344
- // - use a full mount.
345
- //
346
- // Unfortunately, GitLab has many specs which do neither of these. So the simpler thing to do
347
- // is to optionally chain the method call here.
348
- (_this$$refs$baseDropd = (_this$$refs$baseDropd2 = this.$refs.baseDropdown).containsElement) !== null && _this$$refs$baseDropd !== void 0 && _this$$refs$baseDropd.call(_this$$refs$baseDropd2, e.target)) {
341
+ if (this.autoClose && e.target.closest(ITEM_SELECTOR) && // The ref is null when an item action destroys this component before the click bubbles here.
342
+ // The method is optionally chained to accommodate specs that shallow mount without stubbing
343
+ // `BaseDropdown`'s `containsElement`; GitLab has many such specs.
344
+ (_this$$refs$baseDropd = this.$refs.baseDropdown) !== null && _this$$refs$baseDropd !== void 0 && (_this$$refs$baseDropd2 = _this$$refs$baseDropd.containsElement) !== null && _this$$refs$baseDropd2 !== void 0 && _this$$refs$baseDropd2.call(_this$$refs$baseDropd, e.target)) {
349
345
  this.closeAndFocus();
350
346
  }
351
347
  },
@@ -1,4 +1,4 @@
1
- import { extend, isVue3 } from '../../vue';
1
+ import { extend, isVue3, getVue3Constructor } from '../../vue';
2
2
  import { NAME_TRANSPORTER, NAME_TRANSPORTER_TARGET } from '../../constants/components';
3
3
  import { IS_BROWSER } from '../../constants/env';
4
4
  import { HTMLElement } from '../../constants/safe-types';
@@ -193,7 +193,8 @@ const BVTransporter = /*#__PURE__*/extend({
193
193
  return $nodes[0];
194
194
  }
195
195
  }
196
- const Teleport = this.$.appContext.config.globalProperties.constructor.Teleport;
196
+ const _getVue3Constructor = getVue3Constructor(this),
197
+ Teleport = _getVue3Constructor.Teleport;
197
198
  return h(Teleport, {
198
199
  to: this.container
199
200
  }, this.normalizeSlot());
@@ -1,4 +1,4 @@
1
- import { isVue3 } from '../vue';
1
+ import { isVue3, getVue3Constructor } from '../vue';
2
2
 
3
3
  function _arrayLikeToArray(r, a) {
4
4
  (null == a || a > r.length) && (a = r.length);
@@ -119,9 +119,6 @@ const extractEventHandlers = config => {
119
119
  cleanConfig
120
120
  };
121
121
  };
122
- const getVue3Constructor = parent => {
123
- return parent.$.appContext.config.globalProperties.constructor;
124
- };
125
122
  const BUILTIN_DIRECTIVES = ['show', 'model', 'bind', 'cloak', 'else', 'else-if', 'for', 'html', 'if', 'memo', 'on', 'once', 'pre', 'slot', 'text'];
126
123
  const resolveComponentOptions = Component => {
127
124
  const opts = typeof Component === 'function' && Component.options ? {
@@ -41,6 +41,16 @@ if (isGlobalVue3) {
41
41
  };
42
42
  }
43
43
  const isVue3 = instance => Boolean(instance.$);
44
+
45
+ // Roots created with `new (Vue.extend(Comp))()` expose `Comp`, not `Vue`, as the
46
+ // constructor. Walk up to the base so its options are never merged into helpers.
47
+ const getVue3Constructor = instance => {
48
+ let Ctor = instance.$.appContext.config.globalProperties.constructor;
49
+ while (Ctor.super) {
50
+ Ctor = Ctor.super;
51
+ }
52
+ return Ctor;
53
+ };
44
54
  const extend = Vue.extend.bind(Vue);
45
55
  function mergeData() {
46
56
  var _result$attrs, _result$props;
@@ -52,4 +62,4 @@ function mergeData() {
52
62
  };
53
63
  }
54
64
 
55
- export { COMPONENT_UID_KEY, REF_FOR_KEY, extend, isGlobalVue3, isVue3, mergeData };
65
+ export { COMPONENT_UID_KEY, REF_FOR_KEY, extend, getVue3Constructor, isGlobalVue3, isVue3, mergeData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "137.2.4",
3
+ "version": "137.2.5",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -137,7 +137,7 @@
137
137
  "@yarnpkg/lockfile": "^1.1.0",
138
138
  "acorn": "^8.18.0",
139
139
  "acorn-walk": "^8.3.5",
140
- "autoprefixer": "10.6.0",
140
+ "autoprefixer": "10.6.1",
141
141
  "axe-playwright": "^2.2.2",
142
142
  "babel-loader": "^9.2.1",
143
143
  "cypress": "15.21.1",
@@ -370,14 +370,10 @@ export default {
370
370
  if (
371
371
  this.autoClose &&
372
372
  e.target.closest(ITEM_SELECTOR) &&
373
- // The optional chaining here is to accommodate specs that use shallow mounting.
374
- // Ideally, those specs would either:
375
- // - stub out the `BaseDropdown` component to include a stub `containsElement` method, or
376
- // - use a full mount.
377
- //
378
- // Unfortunately, GitLab has many specs which do neither of these. So the simpler thing to do
379
- // is to optionally chain the method call here.
380
- this.$refs.baseDropdown.containsElement?.(e.target)
373
+ // The ref is null when an item action destroys this component before the click bubbles here.
374
+ // The method is optionally chained to accommodate specs that shallow mount without stubbing
375
+ // `BaseDropdown`'s `containsElement`; GitLab has many such specs.
376
+ this.$refs.baseDropdown?.containsElement?.(e.target)
381
377
  ) {
382
378
  this.closeAndFocus();
383
379
  }
@@ -1,4 +1,4 @@
1
- import { isVue3, extend } from '../../vue'
1
+ import { isVue3, extend, getVue3Constructor } from '../../vue'
2
2
  import { NAME_TRANSPORTER, NAME_TRANSPORTER_TARGET } from '../../constants/components'
3
3
  import { IS_BROWSER } from '../../constants/env'
4
4
  import { HTMLElement } from '../../constants/safe-types'
@@ -199,7 +199,7 @@ export const BVTransporter = /*#__PURE__*/ extend({
199
199
  }
200
200
  }
201
201
 
202
- const { Teleport } = this.$.appContext.config.globalProperties.constructor
202
+ const { Teleport } = getVue3Constructor(this)
203
203
 
204
204
  return h(
205
205
  Teleport,
@@ -1,4 +1,4 @@
1
- import { isVue3 } from '../vue'
1
+ import { isVue3, getVue3Constructor } from '../vue'
2
2
 
3
3
  // Regex to detect event handler props: onSomething or onSomethingOnce
4
4
  const EVENT_HANDLER_RE = /^on([A-Z][a-zA-Z]*)$/
@@ -61,10 +61,6 @@ const extractEventHandlers = config => {
61
61
  return { handlers, cleanConfig }
62
62
  }
63
63
 
64
- const getVue3Constructor = parent => {
65
- return parent.$.appContext.config.globalProperties.constructor
66
- }
67
-
68
64
  const BUILTIN_DIRECTIVES = [
69
65
  'show',
70
66
  'model',
@@ -47,6 +47,16 @@ if (isGlobalVue3) {
47
47
 
48
48
  const isVue3 = instance => Boolean(instance.$)
49
49
 
50
+ // Roots created with `new (Vue.extend(Comp))()` expose `Comp`, not `Vue`, as the
51
+ // constructor. Walk up to the base so its options are never merged into helpers.
52
+ const getVue3Constructor = instance => {
53
+ let Ctor = instance.$.appContext.config.globalProperties.constructor
54
+ while (Ctor.super) {
55
+ Ctor = Ctor.super
56
+ }
57
+ return Ctor
58
+ }
59
+
50
60
  const extend = Vue.extend.bind(Vue)
51
61
 
52
62
  function mergeData(...data) {
@@ -54,4 +64,4 @@ function mergeData(...data) {
54
64
  return { ...result, ...(result.attrs ?? {}), ...(result.props ?? {}) }
55
65
  }
56
66
 
57
- export { COMPONENT_UID_KEY, mergeData, isGlobalVue3, isVue3, extend }
67
+ export { COMPONENT_UID_KEY, mergeData, isGlobalVue3, isVue3, getVue3Constructor, extend }