mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-08 17:22:31 +03:00
remove underscore for static methods
This commit is contained in:
+4
-4
@@ -210,7 +210,7 @@ class Tab {
|
||||
|
||||
// Static
|
||||
|
||||
static _jQueryInterface(config) {
|
||||
static jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
const data = Data.getData(this, DATA_KEY) || new Tab(this)
|
||||
|
||||
@@ -224,7 +224,7 @@ class Tab {
|
||||
})
|
||||
}
|
||||
|
||||
static _getInstance(element) {
|
||||
static getInstance(element) {
|
||||
return Data.getData(element, DATA_KEY)
|
||||
}
|
||||
}
|
||||
@@ -251,11 +251,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||
/* istanbul ignore if */
|
||||
if (typeof $ !== 'undefined') {
|
||||
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||
$.fn[NAME] = Tab._jQueryInterface
|
||||
$.fn[NAME] = Tab.jQueryInterface
|
||||
$.fn[NAME].Constructor = Tab
|
||||
$.fn[NAME].noConflict = () => {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT
|
||||
return Tab._jQueryInterface
|
||||
return Tab.jQueryInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -329,26 +329,26 @@ describe('Tab', () => {
|
||||
const el = fixtureEl.querySelector('div')
|
||||
const tab = new Tab(fixtureEl.querySelector('div'))
|
||||
|
||||
expect(Tab._getInstance(el)).not.toBeNull()
|
||||
expect(Tab.getInstance(el)).not.toBeNull()
|
||||
|
||||
tab.dispose()
|
||||
|
||||
expect(Tab._getInstance(el)).toBeNull()
|
||||
expect(Tab.getInstance(el)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('_jQueryInterface', () => {
|
||||
describe('jQueryInterface', () => {
|
||||
it('should create a tab', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.tab = Tab._jQueryInterface
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock)
|
||||
|
||||
expect(Tab._getInstance(div)).toBeDefined()
|
||||
expect(Tab.getInstance(div)).toBeDefined()
|
||||
})
|
||||
|
||||
it('should not re create a tab', () => {
|
||||
@@ -357,12 +357,12 @@ describe('Tab', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const tab = new Tab(div)
|
||||
|
||||
jQueryMock.fn.tab = Tab._jQueryInterface
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock)
|
||||
|
||||
expect(Tab._getInstance(div)).toEqual(tab)
|
||||
expect(Tab.getInstance(div)).toEqual(tab)
|
||||
})
|
||||
|
||||
it('should call a tab method', () => {
|
||||
@@ -373,12 +373,12 @@ describe('Tab', () => {
|
||||
|
||||
spyOn(tab, 'show')
|
||||
|
||||
jQueryMock.fn.tab = Tab._jQueryInterface
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock, 'show')
|
||||
|
||||
expect(Tab._getInstance(div)).toEqual(tab)
|
||||
expect(Tab.getInstance(div)).toEqual(tab)
|
||||
expect(tab.show).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -388,7 +388,7 @@ describe('Tab', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.tab = Tab._jQueryInterface
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
try {
|
||||
@@ -399,9 +399,9 @@ describe('Tab', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('_getInstance', () => {
|
||||
describe('getInstance', () => {
|
||||
it('should return null if there is no instance', () => {
|
||||
expect(Tab._getInstance(fixtureEl)).toEqual(null)
|
||||
expect(Tab.getInstance(fixtureEl)).toEqual(null)
|
||||
})
|
||||
|
||||
it('should return this instance', () => {
|
||||
@@ -410,7 +410,7 @@ describe('Tab', () => {
|
||||
const divEl = fixtureEl.querySelector('div')
|
||||
const tab = new Tab(divEl)
|
||||
|
||||
expect(Tab._getInstance(divEl)).toEqual(tab)
|
||||
expect(Tab.getInstance(divEl)).toEqual(tab)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user