• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

twbs / bootstrap / 15283895011

27 May 2025 07:22PM CUT coverage: 95.999% (-0.07%) from 96.07%
15283895011

push

github

web-flow
Build(deps-dev): Bump the development-dependencies group with 8 updates (#41502)

Bumps the development-dependencies group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@astrojs/markdown-remark](https://github.com/withastro/astro/tree/HEAD/packages/markdown/remark) | `6.3.1` | `6.3.2` |
| [@astrojs/mdx](https://github.com/withastro/astro/tree/HEAD/packages/integrations/mdx) | `4.2.6` | `4.3.0` |
| [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) | `7.27.1` | `7.27.3` |
| [astro](https://github.com/withastro/astro/tree/HEAD/packages/astro) | `5.7.13` | `5.8.0` |
| [npm-run-all2](https://github.com/bcomnes/npm-run-all2) | `8.0.2` | `8.0.4` |
| [rollup](https://github.com/rollup/rollup) | `4.41.0` | `4.41.1` |
| [terser](https://github.com/terser/terser) | `5.39.2` | `5.40.0` |
| [zod](https://github.com/colinhacks/zod) | `3.25.7` | `3.25.30` |



Updates `@astrojs/markdown-remark` from 6.3.1 to 6.3.2
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/markdown/remark/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/@astrojs/markdown-remark@6.3.2/packages/markdown/remark)

Updates `@astrojs/mdx` from 4.2.6 to 4.3.0
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/integrations/mdx/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/@astrojs/mdx@4.3.0/packages/integrations/mdx)

Updates `@astrojs/prism` from 3.2.0 to 3.3.0
- [Release notes](https://github.com/withastro/astro/releases)
- [Changelog](https://github.com/withastro/astro/blob/main/packages/astro-prism/CHANGELOG.md)
- [Commits](https://github.com/withastro/astro/commits/@astrojs/prism@3.3.0/packages/astro-prism)

Updates `@babel/core` from 7.27.1 to 7.27.3
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://gi... (continued)

665 of 726 branches covered (91.6%)

Branch coverage included in aggregate %.

2022 of 2073 relevant lines covered (97.54%)

194.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/js/src/util/focustrap.js
1
/**
2
 * --------------------------------------------------------------------------
3
 * Bootstrap util/focustrap.js
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
 * --------------------------------------------------------------------------
6
 */
7

8
import EventHandler from '../dom/event-handler.js'
9
import SelectorEngine from '../dom/selector-engine.js'
10
import Config from './config.js'
11

12
/**
13
 * Constants
14
 */
15

16
const NAME = 'focustrap'
3✔
17
const DATA_KEY = 'bs.focustrap'
3✔
18
const EVENT_KEY = `.${DATA_KEY}`
3✔
19
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`
3✔
20
const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY}`
3✔
21

22
const TAB_KEY = 'Tab'
3✔
23
const TAB_NAV_FORWARD = 'forward'
3✔
24
const TAB_NAV_BACKWARD = 'backward'
3✔
25

26
const Default = {
3✔
27
  autofocus: true,
28
  trapElement: null // The element to trap focus inside of
29
}
30

31
const DefaultType = {
3✔
32
  autofocus: 'boolean',
33
  trapElement: 'element'
34
}
35

36
/**
37
 * Class definition
38
 */
39

40
class FocusTrap extends Config {
41
  constructor(config) {
42
    super()
113✔
43
    this._config = this._getConfig(config)
113✔
44
    this._isActive = false
113✔
45
    this._lastTabNavDirection = null
113✔
46
  }
47

48
  // Getters
49
  static get Default() {
50
    return Default
113✔
51
  }
52

53
  static get DefaultType() {
54
    return DefaultType
113✔
55
  }
56

57
  static get NAME() {
58
    return NAME
×
59
  }
60

61
  // Public
62
  activate() {
63
    if (this._isActive) {
67!
64
      return
×
65
    }
66

67
    if (this._config.autofocus) {
67✔
68
      this._config.trapElement.focus()
66✔
69
    }
70

71
    EventHandler.off(document, EVENT_KEY) // guard against infinite focus loop
67✔
72
    EventHandler.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event))
67✔
73
    EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event))
67✔
74

75
    this._isActive = true
67✔
76
  }
77

78
  deactivate() {
79
    if (!this._isActive) {
28✔
80
      return
5✔
81
    }
82

83
    this._isActive = false
23✔
84
    EventHandler.off(document, EVENT_KEY)
23✔
85
  }
86

87
  // Private
88
  _handleFocusin(event) {
89
    const { trapElement } = this._config
19✔
90

91
    if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
19✔
92
      return
2✔
93
    }
94

95
    const elements = SelectorEngine.focusableChildren(trapElement)
17✔
96

97
    if (elements.length === 0) {
17✔
98
      trapElement.focus()
14✔
99
    } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
3✔
100
      elements[elements.length - 1].focus()
1✔
101
    } else {
102
      elements[0].focus()
2✔
103
    }
104
  }
105

106
  _handleKeydown(event) {
107
    if (event.key !== TAB_KEY) {
4!
108
      return
×
109
    }
110

111
    this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD
4✔
112
  }
113
}
114

115
export default FocusTrap
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc