Skip to content

Commit 6d55566

Browse files
committed
fix: remove some old browser logics
1 parent 393676a commit 6d55566

File tree

8 files changed

+13
-91
lines changed

8 files changed

+13
-91
lines changed

src/components/tabs/Tabs.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import {
6464
isFunction,
6565
isExist,
6666
isString,
67-
assign,
6867
hasOwnProperty,
6968
} from '../../utils/object.utils'
7069
@@ -106,11 +105,15 @@ export default {
106105
const customNavClass = this.customNavClass
107106
if (isExist(customNavClass)) {
108107
if (isString(customNavClass)) {
109-
return assign({}, tabClasses, {
108+
return {
109+
...tabClasses,
110110
[customNavClass]: true,
111-
})
111+
}
112112
} else {
113-
return assign({}, tabClasses, customNavClass)
113+
return {
114+
...tabClasses,
115+
...customNavClass,
116+
}
114117
}
115118
} else {
116119
return tabClasses
@@ -123,11 +126,9 @@ export default {
123126
const customContentClass = this.customContentClass
124127
if (isExist(customContentClass)) {
125128
if (isString(customContentClass)) {
126-
return assign({}, contentClasses, {
127-
[customContentClass]: true,
128-
})
129+
return { ...contentClasses, [customContentClass]: true }
129130
} else {
130-
return assign({}, contentClasses, customContentClass)
131+
return { ...contentClasses, ...customContentClass }
131132
}
132133
} else {
133134
return contentClasses
@@ -196,7 +197,7 @@ export default {
196197
}
197198
198199
// return with new classes added to tab
199-
return assign(defaultClasses, tab.tabClasses)
200+
return { ...defaultClasses, ...tab.tabClasses }
200201
},
201202
selectCurrent() {
202203
let found = false

src/components/typeahead/Typeahead.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { isString } from '../../utils/object.utils'
3636
import {
3737
on,
3838
off,
39-
ensureElementMatchesFunction,
4039
EVENTS,
4140
getElementBySelectorOrRef,
4241
} from '../../utils/dom.utils'
@@ -49,7 +48,7 @@ export default {
4948
type: null,
5049
required: true,
5150
},
52-
data: { type: Array, default: () => [] },
51+
data: { type: Array, default: undefined },
5352
itemKey: { type: String, default: undefined },
5453
appendToBody: {
5554
type: Boolean,
@@ -143,7 +142,6 @@ export default {
143142
},
144143
},
145144
mounted() {
146-
ensureElementMatchesFunction()
147145
this.$nextTick(() => {
148146
this.initInputElByTarget(this.target)
149147
this.initListeners()

src/directives/scrollspy/scrollspy.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import {
99
getParents,
1010
} from '../../utils/dom.utils'
1111
import { nodeListToArray } from '../../utils/array.utils'
12-
import { assign } from '../../utils/object.utils'
1312

1413
function ScrollSpy(element, target = 'body', options = {}) {
1514
this.el = element
16-
this.opts = assign({}, ScrollSpy.DEFAULTS, options)
15+
this.opts = { ...ScrollSpy.DEFAULTS, ...options }
1716
this.opts.target = target
1817
if (target === 'body') {
1918
this.scrollElement = window

src/mixins/locale.mixin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { t } from '../locale'
2-
import { assign } from '../utils/object.utils'
32

43
export default {
54
methods: {
@@ -8,7 +7,7 @@ export default {
87
for (let i = 0; i < arguments.length; ++i) {
98
args.push(arguments[i])
109
}
11-
args[1] = assign({}, { $$locale: this.locale }, args[1])
10+
args[1] = { $$locale: this.locale, ...args[1] }
1211
return t.apply(this, args)
1312
},
1413
},

src/mixins/popup.mixin.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
PLACEMENTS,
3-
ensureElementMatchesFunction,
43
on,
54
off,
65
EVENTS,
@@ -113,7 +112,6 @@ export default {
113112
},
114113
},
115114
mounted() {
116-
ensureElementMatchesFunction()
117115
removeFromDom(this.$refs.popup)
118116
this.$nextTick(() => {
119117
this.initTriggerElByTarget(this.target)

src/utils/dom.utils.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,6 @@ export function removeFromDom(el) {
113113
isElement(el) && isElement(el.parentNode) && el.parentNode.removeChild(el)
114114
}
115115

116-
export function ensureElementMatchesFunction() {
117-
/* istanbul ignore next */
118-
if (!Element.prototype.matches) {
119-
Element.prototype.matches =
120-
Element.prototype.matchesSelector ||
121-
Element.prototype.mozMatchesSelector ||
122-
Element.prototype.msMatchesSelector ||
123-
Element.prototype.oMatchesSelector ||
124-
Element.prototype.webkitMatchesSelector ||
125-
function (s) {
126-
const matches = (this.document || this.ownerDocument).querySelectorAll(
127-
s
128-
)
129-
let i = matches.length
130-
// eslint-disable-next-line no-empty
131-
while (--i >= 0 && matches.item(i) !== this) {}
132-
return i > -1
133-
}
134-
}
135-
}
136-
137116
export function addClass(el, className) {
138117
if (!isElement(el)) {
139118
return
@@ -405,7 +384,6 @@ export function toggleBodyOverflow(enable) {
405384
}
406385

407386
export function getClosest(el, selector) {
408-
ensureElementMatchesFunction()
409387
let parent
410388
let _el = el
411389
while (_el) {
@@ -419,7 +397,6 @@ export function getClosest(el, selector) {
419397
}
420398

421399
export function getParents(el, selector, until = null) {
422-
ensureElementMatchesFunction()
423400
const parents = []
424401
let parent = el.parentElement
425402
while (parent) {

src/utils/object.utils.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
2-
export function assign(target, varArgs) {
3-
if (target === null || target === undefined) {
4-
throw new TypeError('Cannot convert undefined or null to object')
5-
}
6-
const to = Object(target)
7-
for (let index = 1; index < arguments.length; index++) {
8-
const nextSource = arguments[index]
9-
if (nextSource !== null && nextSource !== undefined) {
10-
for (const nextKey in nextSource) {
11-
// Avoid bugs when hasOwnProperty is shadowed
12-
/* istanbul ignore else */
13-
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
14-
to[nextKey] = nextSource[nextKey]
15-
}
16-
}
17-
}
18-
}
19-
return to
20-
}
21-
221
export function isExist(obj) {
232
return typeof obj !== 'undefined' && obj !== null
243
}

src/utils/object.utils.spec.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,6 @@
11
import * as utils from './object.utils'
22

33
describe('object.utils', () => {
4-
describe('#assign', () => {
5-
it('should be able to merge objects', () => {
6-
expect(utils.assign({}, { a: 1 }, { a: 2, b: 3 })).toEqual({
7-
a: 2,
8-
b: 3,
9-
})
10-
})
11-
12-
it('should be able to handle null target', () => {
13-
expect(utils.assign.bind(this, null, {})).toThrow(
14-
'Cannot convert undefined or null to object'
15-
)
16-
})
17-
18-
it('should be able to handle null or undefined source', () => {
19-
expect(
20-
utils.assign({}, { a: 1 }, null, undefined, { a: 2, b: 3 })
21-
).toEqual({ a: 2, b: 3 })
22-
})
23-
24-
it('should be able to avoid prototype properties', () => {
25-
// eslint-disable-next-line no-new-func
26-
const a = new Function()
27-
a.prototype.b = 1
28-
a.c = 2
29-
expect(utils.assign({}, a)).toEqual({ c: 2 })
30-
})
31-
})
32-
334
describe('#isExist ', () => {
345
it('should be able return false if null', () => {
356
expect(utils.isExist(null)).toBeFalsy()

0 commit comments

Comments
 (0)