mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-05 16:42:29 +03:00
remove underscore for static methods
This commit is contained in:
+10
-10
@@ -528,7 +528,7 @@ class Carousel {
|
||||
|
||||
// Static
|
||||
|
||||
static _carouselInterface(element, config) {
|
||||
static carouselInterface(element, config) {
|
||||
let data = Data.getData(element, DATA_KEY)
|
||||
let _config = {
|
||||
...Default,
|
||||
@@ -562,13 +562,13 @@ class Carousel {
|
||||
}
|
||||
}
|
||||
|
||||
static _jQueryInterface(config) {
|
||||
static jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
Carousel._carouselInterface(this, config)
|
||||
Carousel.carouselInterface(this, config)
|
||||
})
|
||||
}
|
||||
|
||||
static _dataApiClickHandler(event) {
|
||||
static dataApiClickHandler(event) {
|
||||
const target = getElementFromSelector(this)
|
||||
|
||||
if (!target || !target.classList.contains(ClassName.CAROUSEL)) {
|
||||
@@ -585,7 +585,7 @@ class Carousel {
|
||||
config.interval = false
|
||||
}
|
||||
|
||||
Carousel._carouselInterface(target, config)
|
||||
Carousel.carouselInterface(target, config)
|
||||
|
||||
if (slideIndex) {
|
||||
Data.getData(target, DATA_KEY).to(slideIndex)
|
||||
@@ -594,7 +594,7 @@ class Carousel {
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
static _getInstance(element) {
|
||||
static getInstance(element) {
|
||||
return Data.getData(element, DATA_KEY)
|
||||
}
|
||||
}
|
||||
@@ -606,12 +606,12 @@ class Carousel {
|
||||
*/
|
||||
|
||||
EventHandler
|
||||
.on(document, Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler)
|
||||
.on(document, Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel.dataApiClickHandler)
|
||||
|
||||
EventHandler.on(window, Event.LOAD_DATA_API, () => {
|
||||
const carousels = makeArray(SelectorEngine.find(Selector.DATA_RIDE))
|
||||
for (let i = 0, len = carousels.length; i < len; i++) {
|
||||
Carousel._carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
|
||||
Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -624,11 +624,11 @@ EventHandler.on(window, Event.LOAD_DATA_API, () => {
|
||||
/* istanbul ignore if */
|
||||
if (typeof $ !== 'undefined') {
|
||||
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||
$.fn[NAME] = Carousel._jQueryInterface
|
||||
$.fn[NAME] = Carousel.jQueryInterface
|
||||
$.fn[NAME].Constructor = Carousel
|
||||
$.fn[NAME].noConflict = () => {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT
|
||||
return Carousel._jQueryInterface
|
||||
return Carousel.jQueryInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1037,18 +1037,18 @@ describe('Carousel', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('_jQueryInterface', () => {
|
||||
describe('jQueryInterface', () => {
|
||||
it('should create a carousel', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.carousel = Carousel._jQueryInterface
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock)
|
||||
|
||||
expect(Carousel._getInstance(div)).toBeDefined()
|
||||
expect(Carousel.getInstance(div)).toBeDefined()
|
||||
})
|
||||
|
||||
it('should not re create a carousel', () => {
|
||||
@@ -1057,12 +1057,12 @@ describe('Carousel', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const carousel = new Carousel(div)
|
||||
|
||||
jQueryMock.fn.carousel = Carousel._jQueryInterface
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock)
|
||||
|
||||
expect(Carousel._getInstance(div)).toEqual(carousel)
|
||||
expect(Carousel.getInstance(div)).toEqual(carousel)
|
||||
})
|
||||
|
||||
it('should call to if the config is a number', () => {
|
||||
@@ -1074,7 +1074,7 @@ describe('Carousel', () => {
|
||||
|
||||
spyOn(carousel, 'to')
|
||||
|
||||
jQueryMock.fn.carousel = Carousel._jQueryInterface
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock, slideTo)
|
||||
@@ -1088,7 +1088,7 @@ describe('Carousel', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.carousel = Carousel._jQueryInterface
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
try {
|
||||
@@ -1108,7 +1108,7 @@ describe('Carousel', () => {
|
||||
|
||||
window.dispatchEvent(loadEvent)
|
||||
|
||||
expect(Carousel._getInstance(carouselEl)).toBeDefined()
|
||||
expect(Carousel.getInstance(carouselEl)).toBeDefined()
|
||||
})
|
||||
|
||||
it('should create carousel and go to the next slide on click', done => {
|
||||
|
||||
Reference in New Issue
Block a user