8000 refactor: move `getUID` function to utils · coreui/coreui-vue@c99efaa · GitHub
[go: up one dir, main page]

Skip to content

Commit c99efaa

Browse files
committed
refactor: move getUID function to utils
1 parent 9c49d53 commit c99efaa

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

packages/coreui-vue/src/directives/v-c-popover.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { DirectiveBinding } from 'vue'
22
import { createPopper } from '@popperjs/core'
33

4-
const getUID = (prefix: string) => {
5-
do {
6-
prefix += Math.floor(Math.random() * 1000000)
7-
} while (document.getElementById(prefix))
8-
9-
return prefix
10-
}
4+
import { getUID } from '../utils'
115

126
const createPopoverElement = (id: string, header: string, content: string): HTMLDivElement => {
137
const popover = document.createElement('div')

packages/coreui-vue/src/directives/v-c-tooltip.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { DirectiveBinding } from 'vue'
22
import { createPopper } from '@popperjs/core'
33

4-
const getUID = (prefix: string) => {
5-
do {
6-
prefix += Math.floor(Math.random() * 1000000)
7-
} while (document.getElementById(prefix))
8-
9-
return prefix
10-
}
4+
import { getUID } from '../utils'
115

126
const createTooltipElement = (id: string, content: string): HTMLDivElement => {
137
const tooltip = document.createElement('div')
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const getUID = (prefix: string) => {
2+
do {
3+
prefix += Math.floor(Math.random() * 1_000_000)
4+
} while (document.getElementById(prefix))
5+
6+
return prefix
7+
}
8+
9+
export default getUID
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
import getUID from './getUID'
12
import isInViewport from './isInViewport'
23
import isRTL from './isRTL'
34

4-
export { isInViewport, isRTL }
5+
export { getUID, isInViewport, isRTL }

0 commit comments

Comments
 (0)
0