0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

remove underscore for static methods

This commit is contained in:
Johann-S 2019-07-28 15:24:46 +02:00
parent 144220f0c5
commit dcba526775
32 changed files with 215 additions and 215 deletions

View File

@ -128,7 +128,7 @@ class Alert {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
@ -142,7 +142,7 @@ class Alert {
}) })
} }
static _handleDismiss(alertInstance) { static handleDismiss(alertInstance) {
return function (event) { return function (event) {
if (event) { if (event) {
event.preventDefault() event.preventDefault()
@ -152,7 +152,7 @@ class Alert {
} }
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -163,7 +163,7 @@ class Alert {
* ------------------------------------------------------------------------ * ------------------------------------------------------------------------
*/ */
EventHandler EventHandler
.on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())) .on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert.handleDismiss(new Alert()))
/** /**
* ------------------------------------------------------------------------ * ------------------------------------------------------------------------
@ -175,11 +175,11 @@ EventHandler
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Alert._jQueryInterface $.fn[NAME] = Alert.jQueryInterface
$.fn[NAME].Constructor = Alert $.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface return Alert.jQueryInterface
} }
} }

View File

@ -117,15 +117,15 @@ describe('Alert', () => {
const alertEl = document.querySelector('.alert') const alertEl = document.querySelector('.alert')
const alert = new Alert(alertEl) const alert = new Alert(alertEl)
expect(Alert._getInstance(alertEl)).toBeDefined() expect(Alert.getInstance(alertEl)).toBeDefined()
alert.dispose() alert.dispose()
expect(Alert._getInstance(alertEl)).toBeNull() expect(Alert.getInstance(alertEl)).toBeNull()
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should handle config passed and toggle existing alert', () => { it('should handle config passed and toggle existing alert', () => {
fixtureEl.innerHTML = '<div class="alert"></div>' fixtureEl.innerHTML = '<div class="alert"></div>'
@ -134,7 +134,7 @@ describe('Alert', () => {
spyOn(alert, 'close') spyOn(alert, 'close')
jQueryMock.fn.alert = Alert._jQueryInterface jQueryMock.fn.alert = Alert.jQueryInterface
jQueryMock.elements = [alertEl] jQueryMock.elements = [alertEl]
jQueryMock.fn.alert.call(jQueryMock, 'close') jQueryMock.fn.alert.call(jQueryMock, 'close')
@ -147,12 +147,12 @@ describe('Alert', () => {
const alertEl = fixtureEl.querySelector('.alert') const alertEl = fixtureEl.querySelector('.alert')
jQueryMock.fn.alert = Alert._jQueryInterface jQueryMock.fn.alert = Alert.jQueryInterface
jQueryMock.elements = [alertEl] jQueryMock.elements = [alertEl]
jQueryMock.fn.alert.call(jQueryMock, 'close') jQueryMock.fn.alert.call(jQueryMock, 'close')
expect(Alert._getInstance(alertEl)).toBeDefined() expect(Alert.getInstance(alertEl)).toBeDefined()
expect(fixtureEl.querySelector('.alert')).toBeNull() expect(fixtureEl.querySelector('.alert')).toBeNull()
}) })
@ -161,12 +161,12 @@ describe('Alert', () => {
const alertEl = fixtureEl.querySelector('.alert') const alertEl = fixtureEl.querySelector('.alert')
jQueryMock.fn.alert = Alert._jQueryInterface jQueryMock.fn.alert = Alert.jQueryInterface
jQueryMock.elements = [alertEl] jQueryMock.elements = [alertEl]
jQueryMock.fn.alert.call(jQueryMock) jQueryMock.fn.alert.call(jQueryMock)
expect(Alert._getInstance(alertEl)).toBeDefined() expect(Alert.getInstance(alertEl)).toBeDefined()
expect(fixtureEl.querySelector('.alert')).not.toBeNull() expect(fixtureEl.querySelector('.alert')).not.toBeNull()
}) })
}) })

View File

@ -122,7 +122,7 @@ class Button {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
@ -136,7 +136,7 @@ class Button {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -188,12 +188,12 @@ EventHandler.on(document, Event.BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, even
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Button._jQueryInterface $.fn[NAME] = Button.jQueryInterface
$.fn[NAME].Constructor = Button $.fn[NAME].Constructor = Button
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Button._jQueryInterface return Button.jQueryInterface
} }
} }

View File

@ -236,15 +236,15 @@ describe('Button', () => {
const btnEl = fixtureEl.querySelector('.btn') const btnEl = fixtureEl.querySelector('.btn')
const button = new Button(btnEl) const button = new Button(btnEl)
expect(Button._getInstance(btnEl)).toBeDefined() expect(Button.getInstance(btnEl)).toBeDefined()
button.dispose() button.dispose()
expect(Button._getInstance(btnEl)).toBeNull() expect(Button.getInstance(btnEl)).toBeNull()
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should handle config passed and toggle existing button', () => { it('should handle config passed and toggle existing button', () => {
fixtureEl.innerHTML = '<button class="btn" data-toggle="button"></button>' fixtureEl.innerHTML = '<button class="btn" data-toggle="button"></button>'
@ -253,7 +253,7 @@ describe('Button', () => {
spyOn(button, 'toggle') spyOn(button, 'toggle')
jQueryMock.fn.button = Button._jQueryInterface jQueryMock.fn.button = Button.jQueryInterface
jQueryMock.elements = [btnEl] jQueryMock.elements = [btnEl]
jQueryMock.fn.button.call(jQueryMock, 'toggle') jQueryMock.fn.button.call(jQueryMock, 'toggle')
@ -266,12 +266,12 @@ describe('Button', () => {
const btnEl = fixtureEl.querySelector('.btn') const btnEl = fixtureEl.querySelector('.btn')
jQueryMock.fn.button = Button._jQueryInterface jQueryMock.fn.button = Button.jQueryInterface
jQueryMock.elements = [btnEl] jQueryMock.elements = [btnEl]
jQueryMock.fn.button.call(jQueryMock, 'toggle') jQueryMock.fn.button.call(jQueryMock, 'toggle')
expect(Button._getInstance(btnEl)).toBeDefined() expect(Button.getInstance(btnEl)).toBeDefined()
expect(btnEl.classList.contains('active')).toEqual(true) expect(btnEl.classList.contains('active')).toEqual(true)
}) })
@ -280,12 +280,12 @@ describe('Button', () => {
const btnEl = fixtureEl.querySelector('.btn') const btnEl = fixtureEl.querySelector('.btn')
jQueryMock.fn.button = Button._jQueryInterface jQueryMock.fn.button = Button.jQueryInterface
jQueryMock.elements = [btnEl] jQueryMock.elements = [btnEl]
jQueryMock.fn.button.call(jQueryMock) jQueryMock.fn.button.call(jQueryMock)
expect(Button._getInstance(btnEl)).toBeDefined() expect(Button.getInstance(btnEl)).toBeDefined()
expect(btnEl.classList.contains('active')).toEqual(false) expect(btnEl.classList.contains('active')).toEqual(false)
}) })
}) })

View File

@ -528,7 +528,7 @@ class Carousel {
// Static // Static
static _carouselInterface(element, config) { static carouselInterface(element, config) {
let data = Data.getData(element, DATA_KEY) let data = Data.getData(element, DATA_KEY)
let _config = { let _config = {
...Default, ...Default,
@ -562,13 +562,13 @@ class Carousel {
} }
} }
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
Carousel._carouselInterface(this, config) Carousel.carouselInterface(this, config)
}) })
} }
static _dataApiClickHandler(event) { static dataApiClickHandler(event) {
const target = getElementFromSelector(this) const target = getElementFromSelector(this)
if (!target || !target.classList.contains(ClassName.CAROUSEL)) { if (!target || !target.classList.contains(ClassName.CAROUSEL)) {
@ -585,7 +585,7 @@ class Carousel {
config.interval = false config.interval = false
} }
Carousel._carouselInterface(target, config) Carousel.carouselInterface(target, config)
if (slideIndex) { if (slideIndex) {
Data.getData(target, DATA_KEY).to(slideIndex) Data.getData(target, DATA_KEY).to(slideIndex)
@ -594,7 +594,7 @@ class Carousel {
event.preventDefault() event.preventDefault()
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -606,12 +606,12 @@ class Carousel {
*/ */
EventHandler 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, () => { EventHandler.on(window, Event.LOAD_DATA_API, () => {
const carousels = makeArray(SelectorEngine.find(Selector.DATA_RIDE)) const carousels = makeArray(SelectorEngine.find(Selector.DATA_RIDE))
for (let i = 0, len = carousels.length; i < len; i++) { 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 */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Carousel._jQueryInterface $.fn[NAME] = Carousel.jQueryInterface
$.fn[NAME].Constructor = Carousel $.fn[NAME].Constructor = Carousel
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Carousel._jQueryInterface return Carousel.jQueryInterface
} }
} }

View File

@ -1037,18 +1037,18 @@ describe('Carousel', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a carousel', () => { it('should create a carousel', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.carousel = Carousel._jQueryInterface jQueryMock.fn.carousel = Carousel.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.carousel.call(jQueryMock) jQueryMock.fn.carousel.call(jQueryMock)
expect(Carousel._getInstance(div)).toBeDefined() expect(Carousel.getInstance(div)).toBeDefined()
}) })
it('should not re create a carousel', () => { it('should not re create a carousel', () => {
@ -1057,12 +1057,12 @@ describe('Carousel', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const carousel = new Carousel(div) const carousel = new Carousel(div)
jQueryMock.fn.carousel = Carousel._jQueryInterface jQueryMock.fn.carousel = Carousel.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.carousel.call(jQueryMock) 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', () => { it('should call to if the config is a number', () => {
@ -1074,7 +1074,7 @@ describe('Carousel', () => {
spyOn(carousel, 'to') spyOn(carousel, 'to')
jQueryMock.fn.carousel = Carousel._jQueryInterface jQueryMock.fn.carousel = Carousel.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.carousel.call(jQueryMock, slideTo) jQueryMock.fn.carousel.call(jQueryMock, slideTo)
@ -1088,7 +1088,7 @@ describe('Carousel', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.carousel = Carousel._jQueryInterface jQueryMock.fn.carousel = Carousel.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -1108,7 +1108,7 @@ describe('Carousel', () => {
window.dispatchEvent(loadEvent) 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 => { it('should create carousel and go to the next slide on click', done => {

View File

@ -173,7 +173,7 @@ class Collapse {
if (actives) { if (actives) {
actives.forEach(elemActive => { actives.forEach(elemActive => {
if (container !== elemActive) { if (container !== elemActive) {
Collapse._collapseInterface(elemActive, 'hide') Collapse.collapseInterface(elemActive, 'hide')
} }
if (!activesData) { if (!activesData) {
@ -348,7 +348,7 @@ class Collapse {
// Static // Static
static _collapseInterface(element, config) { static collapseInterface(element, config) {
let data = Data.getData(element, DATA_KEY) let data = Data.getData(element, DATA_KEY)
const _config = { const _config = {
...Default, ...Default,
@ -373,13 +373,13 @@ class Collapse {
} }
} }
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
Collapse._collapseInterface(this, config) Collapse.collapseInterface(this, config)
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -415,7 +415,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
config = triggerData config = triggerData
} }
Collapse._collapseInterface(element, config) Collapse.collapseInterface(element, config)
}) })
}) })
@ -428,11 +428,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Collapse._jQueryInterface $.fn[NAME] = Collapse.jQueryInterface
$.fn[NAME].Constructor = Collapse $.fn[NAME].Constructor = Collapse
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Collapse._jQueryInterface return Collapse.jQueryInterface
} }
} }

View File

@ -366,11 +366,11 @@ describe('Collapse', () => {
toggle: false toggle: false
}) })
expect(Collapse._getInstance(collapseEl)).toEqual(collapse) expect(Collapse.getInstance(collapseEl)).toEqual(collapse)
collapse.dispose() collapse.dispose()
expect(Collapse._getInstance(collapseEl)).toEqual(null) expect(Collapse.getInstance(collapseEl)).toEqual(null)
}) })
}) })
@ -760,18 +760,18 @@ describe('Collapse', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a collapse', () => { it('should create a collapse', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.collapse = Collapse._jQueryInterface jQueryMock.fn.collapse = Collapse.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.collapse.call(jQueryMock) jQueryMock.fn.collapse.call(jQueryMock)
expect(Collapse._getInstance(div)).toBeDefined() expect(Collapse.getInstance(div)).toBeDefined()
}) })
it('should not re create a collapse', () => { it('should not re create a collapse', () => {
@ -780,12 +780,12 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const collapse = new Collapse(div) const collapse = new Collapse(div)
jQueryMock.fn.collapse = Collapse._jQueryInterface jQueryMock.fn.collapse = Collapse.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.collapse.call(jQueryMock) jQueryMock.fn.collapse.call(jQueryMock)
expect(Collapse._getInstance(div)).toEqual(collapse) expect(Collapse.getInstance(div)).toEqual(collapse)
}) })
it('should throw error on undefined method', () => { it('should throw error on undefined method', () => {
@ -794,7 +794,7 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.collapse = Collapse._jQueryInterface jQueryMock.fn.collapse = Collapse.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -805,14 +805,14 @@ describe('Collapse', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return collapse instance', () => { it('should return collapse instance', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const collapse = new Collapse(div) const collapse = new Collapse(div)
expect(Collapse._getInstance(div)).toEqual(collapse) expect(Collapse.getInstance(div)).toEqual(collapse)
}) })
it('should return null when there is no collapse instance', () => { it('should return null when there is no collapse instance', () => {
@ -820,7 +820,7 @@ describe('Collapse', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
expect(Collapse._getInstance(div)).toEqual(null) expect(Collapse.getInstance(div)).toEqual(null)
}) })
}) })
}) })

View File

@ -133,10 +133,10 @@ class Dropdown {
return return
} }
const parent = Dropdown._getParentFromElement(this._element) const parent = Dropdown.getParentFromElement(this._element)
const isActive = this._menu.classList.contains(ClassName.SHOW) const isActive = this._menu.classList.contains(ClassName.SHOW)
Dropdown._clearMenus() Dropdown.clearMenus()
if (isActive) { if (isActive) {
return return
@ -207,7 +207,7 @@ class Dropdown {
return return
} }
const parent = Dropdown._getParentFromElement(this._element) const parent = Dropdown.getParentFromElement(this._element)
const relatedTarget = { const relatedTarget = {
relatedTarget: this._element relatedTarget: this._element
} }
@ -228,7 +228,7 @@ class Dropdown {
return return
} }
const parent = Dropdown._getParentFromElement(this._element) const parent = Dropdown.getParentFromElement(this._element)
const relatedTarget = { const relatedTarget = {
relatedTarget: this._element relatedTarget: this._element
} }
@ -289,7 +289,7 @@ class Dropdown {
} }
_getMenuElement() { _getMenuElement() {
const parent = Dropdown._getParentFromElement(this._element) const parent = Dropdown.getParentFromElement(this._element)
return SelectorEngine.findOne(Selector.MENU, parent) return SelectorEngine.findOne(Selector.MENU, parent)
} }
@ -364,7 +364,7 @@ class Dropdown {
// Static // Static
static _dropdownInterface(element, config) { static dropdownInterface(element, config) {
let data = Data.getData(element, DATA_KEY) let data = Data.getData(element, DATA_KEY)
const _config = typeof config === 'object' ? config : null const _config = typeof config === 'object' ? config : null
@ -381,13 +381,13 @@ class Dropdown {
} }
} }
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
Dropdown._dropdownInterface(this, config) Dropdown.dropdownInterface(this, config)
}) })
} }
static _clearMenus(event) { static clearMenus(event) {
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH ||
event.type === 'keyup' && event.which !== TAB_KEYCODE)) { event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
return return
@ -395,7 +395,7 @@ class Dropdown {
const toggles = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE)) const toggles = makeArray(SelectorEngine.find(Selector.DATA_TOGGLE))
for (let i = 0, len = toggles.length; i < len; i++) { for (let i = 0, len = toggles.length; i < len; i++) {
const parent = Dropdown._getParentFromElement(toggles[i]) const parent = Dropdown.getParentFromElement(toggles[i])
const context = Data.getData(toggles[i], DATA_KEY) const context = Data.getData(toggles[i], DATA_KEY)
const relatedTarget = { const relatedTarget = {
relatedTarget: toggles[i] relatedTarget: toggles[i]
@ -441,11 +441,11 @@ class Dropdown {
} }
} }
static _getParentFromElement(element) { static getParentFromElement(element) {
return getElementFromSelector(element) || element.parentNode return getElementFromSelector(element) || element.parentNode
} }
static _dataApiKeydownHandler(event) { static dataApiKeydownHandler(event) {
// If not input/textarea: // If not input/textarea:
// - And not a key in REGEXP_KEYDOWN => not a dropdown command // - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea: // If input/textarea:
@ -468,7 +468,7 @@ class Dropdown {
return return
} }
const parent = Dropdown._getParentFromElement(this) const parent = Dropdown.getParentFromElement(this)
const isActive = parent.classList.contains(ClassName.SHOW) const isActive = parent.classList.contains(ClassName.SHOW)
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
@ -476,7 +476,7 @@ class Dropdown {
SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus() SelectorEngine.findOne(Selector.DATA_TOGGLE, parent).focus()
} }
Dropdown._clearMenus() Dropdown.clearMenus()
return return
} }
@ -503,7 +503,7 @@ class Dropdown {
items[index].focus() items[index].focus()
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -514,14 +514,14 @@ class Dropdown {
* ------------------------------------------------------------------------ * ------------------------------------------------------------------------
*/ */
EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler) EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown.dataApiKeydownHandler)
EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler) EventHandler.on(document, Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown.dataApiKeydownHandler)
EventHandler.on(document, Event.CLICK_DATA_API, Dropdown._clearMenus) EventHandler.on(document, Event.CLICK_DATA_API, Dropdown.clearMenus)
EventHandler.on(document, Event.KEYUP_DATA_API, Dropdown._clearMenus) EventHandler.on(document, Event.KEYUP_DATA_API, Dropdown.clearMenus)
EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
Dropdown._dropdownInterface(this, 'toggle') Dropdown.dropdownInterface(this, 'toggle')
}) })
EventHandler EventHandler
.on(document, Event.CLICK_DATA_API, Selector.FORM_CHILD, e => e.stopPropagation()) .on(document, Event.CLICK_DATA_API, Selector.FORM_CHILD, e => e.stopPropagation())
@ -535,11 +535,11 @@ EventHandler
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Dropdown._jQueryInterface $.fn[NAME] = Dropdown.jQueryInterface
$.fn[NAME].Constructor = Dropdown $.fn[NAME].Constructor = Dropdown
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Dropdown._jQueryInterface return Dropdown.jQueryInterface
} }
} }

View File

@ -1412,18 +1412,18 @@ describe('Dropdown', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a dropdown', () => { it('should create a dropdown', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.dropdown = Dropdown._jQueryInterface jQueryMock.fn.dropdown = Dropdown.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.dropdown.call(jQueryMock) jQueryMock.fn.dropdown.call(jQueryMock)
expect(Dropdown._getInstance(div)).toBeDefined() expect(Dropdown.getInstance(div)).toBeDefined()
}) })
it('should not re create a dropdown', () => { it('should not re create a dropdown', () => {
@ -1432,12 +1432,12 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const dropdown = new Dropdown(div) const dropdown = new Dropdown(div)
jQueryMock.fn.dropdown = Dropdown._jQueryInterface jQueryMock.fn.dropdown = Dropdown.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.dropdown.call(jQueryMock) jQueryMock.fn.dropdown.call(jQueryMock)
expect(Dropdown._getInstance(div)).toEqual(dropdown) expect(Dropdown.getInstance(div)).toEqual(dropdown)
}) })
it('should throw error on undefined method', () => { it('should throw error on undefined method', () => {
@ -1446,7 +1446,7 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.dropdown = Dropdown._jQueryInterface jQueryMock.fn.dropdown = Dropdown.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -1457,14 +1457,14 @@ describe('Dropdown', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return dropdown instance', () => { it('should return dropdown instance', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const dropdown = new Dropdown(div) const dropdown = new Dropdown(div)
expect(Dropdown._getInstance(div)).toEqual(dropdown) expect(Dropdown.getInstance(div)).toEqual(dropdown)
}) })
it('should return null when there is no dropdown instance', () => { it('should return null when there is no dropdown instance', () => {
@ -1472,7 +1472,7 @@ describe('Dropdown', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
expect(Dropdown._getInstance(div)).toEqual(null) expect(Dropdown.getInstance(div)).toEqual(null)
}) })
}) })
}) })

View File

@ -513,7 +513,7 @@ class Modal {
// Static // Static
static _jQueryInterface(config, relatedTarget) { static jQueryInterface(config, relatedTarget) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
const _config = { const _config = {
@ -538,7 +538,7 @@ class Modal {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -591,11 +591,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Modal._jQueryInterface $.fn[NAME] = Modal.jQueryInterface
$.fn[NAME].Constructor = Modal $.fn[NAME].Constructor = Modal
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Modal._jQueryInterface return Modal.jQueryInterface
} }
} }

View File

@ -711,13 +711,13 @@ describe('Modal', () => {
const modalEl = fixtureEl.querySelector('.modal') const modalEl = fixtureEl.querySelector('.modal')
const modal = new Modal(modalEl) const modal = new Modal(modalEl)
expect(Modal._getInstance(modalEl)).toEqual(modal) expect(Modal.getInstance(modalEl)).toEqual(modal)
spyOn(EventHandler, 'off') spyOn(EventHandler, 'off')
modal.dispose() modal.dispose()
expect(Modal._getInstance(modalEl)).toEqual(null) expect(Modal.getInstance(modalEl)).toEqual(null)
expect(EventHandler.off).toHaveBeenCalledTimes(4) expect(EventHandler.off).toHaveBeenCalledTimes(4)
}) })
}) })
@ -813,7 +813,7 @@ describe('Modal', () => {
spyOn(trigger, 'focus') spyOn(trigger, 'focus')
modalEl.addEventListener('shown.bs.modal', () => { modalEl.addEventListener('shown.bs.modal', () => {
const modal = Modal._getInstance(modalEl) const modal = Modal.getInstance(modalEl)
modal.hide() modal.hide()
}) })
@ -844,7 +844,7 @@ describe('Modal', () => {
spyOn(trigger, 'focus') spyOn(trigger, 'focus')
modalEl.addEventListener('shown.bs.modal', () => { modalEl.addEventListener('shown.bs.modal', () => {
const modal = Modal._getInstance(modalEl) const modal = Modal.getInstance(modalEl)
modal.hide() modal.hide()
}) })
@ -890,18 +890,18 @@ describe('Modal', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a modal', () => { it('should create a modal', () => {
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog" /></div>' fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog" /></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.modal = Modal._jQueryInterface jQueryMock.fn.modal = Modal.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.modal.call(jQueryMock) jQueryMock.fn.modal.call(jQueryMock)
expect(Modal._getInstance(div)).toBeDefined() expect(Modal.getInstance(div)).toBeDefined()
}) })
it('should not re create a modal', () => { it('should not re create a modal', () => {
@ -910,12 +910,12 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const modal = new Modal(div) const modal = new Modal(div)
jQueryMock.fn.modal = Modal._jQueryInterface jQueryMock.fn.modal = Modal.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.modal.call(jQueryMock) jQueryMock.fn.modal.call(jQueryMock)
expect(Modal._getInstance(div)).toEqual(modal) expect(Modal.getInstance(div)).toEqual(modal)
}) })
it('should throw error on undefined method', () => { it('should throw error on undefined method', () => {
@ -924,7 +924,7 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.modal = Modal._jQueryInterface jQueryMock.fn.modal = Modal.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -940,7 +940,7 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const modal = new Modal(div) const modal = new Modal(div)
jQueryMock.fn.modal = Modal._jQueryInterface jQueryMock.fn.modal = Modal.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
spyOn(modal, 'show') spyOn(modal, 'show')
@ -955,7 +955,7 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.modal = Modal._jQueryInterface jQueryMock.fn.modal = Modal.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
spyOn(Modal.prototype, 'show') spyOn(Modal.prototype, 'show')
@ -966,14 +966,14 @@ describe('Modal', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return modal instance', () => { it('should return modal instance', () => {
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog" /></div>' fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog" /></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const modal = new Modal(div) const modal = new Modal(div)
expect(Modal._getInstance(div)).toEqual(modal) expect(Modal.getInstance(div)).toEqual(modal)
}) })
it('should return null when there is no modal instance', () => { it('should return null when there is no modal instance', () => {
@ -981,7 +981,7 @@ describe('Modal', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
expect(Modal._getInstance(div)).toEqual(null) expect(Modal.getInstance(div)).toEqual(null)
}) })
}) })
}) })

View File

@ -144,7 +144,7 @@ class Popover extends Tooltip {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
const _config = typeof config === 'object' ? config : null const _config = typeof config === 'object' ? config : null
@ -168,7 +168,7 @@ class Popover extends Tooltip {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -181,11 +181,11 @@ class Popover extends Tooltip {
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Popover._jQueryInterface $.fn[NAME] = Popover.jQueryInterface
$.fn[NAME].Constructor = Popover $.fn[NAME].Constructor = Popover
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Popover._jQueryInterface return Popover.jQueryInterface
} }
} }

View File

@ -139,18 +139,18 @@ describe('Popover', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a popover', () => { it('should create a popover', () => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-content="https://twitter.com/getbootstrap">BS twitter</a>' fixtureEl.innerHTML = '<a href="#" title="Popover" data-content="https://twitter.com/getbootstrap">BS twitter</a>'
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
jQueryMock.fn.popover.call(jQueryMock) jQueryMock.fn.popover.call(jQueryMock)
expect(Popover._getInstance(popoverEl)).toBeDefined() expect(Popover.getInstance(popoverEl)).toBeDefined()
}) })
it('should create a popover with a config object', () => { it('should create a popover with a config object', () => {
@ -158,14 +158,14 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
jQueryMock.fn.popover.call(jQueryMock, { jQueryMock.fn.popover.call(jQueryMock, {
content: 'Popover content' content: 'Popover content'
}) })
expect(Popover._getInstance(popoverEl)).toBeDefined() expect(Popover.getInstance(popoverEl)).toBeDefined()
}) })
it('should not re create a popover', () => { it('should not re create a popover', () => {
@ -174,12 +174,12 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl) const popover = new Popover(popoverEl)
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
jQueryMock.fn.popover.call(jQueryMock) jQueryMock.fn.popover.call(jQueryMock)
expect(Popover._getInstance(popoverEl)).toEqual(popover) expect(Popover.getInstance(popoverEl)).toEqual(popover)
}) })
it('should throw error on undefined method', () => { it('should throw error on undefined method', () => {
@ -188,7 +188,7 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
try { try {
@ -204,7 +204,7 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl) const popover = new Popover(popoverEl)
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
spyOn(popover, 'show') spyOn(popover, 'show')
@ -219,7 +219,7 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
jQueryMock.fn.popover = Popover._jQueryInterface jQueryMock.fn.popover = Popover.jQueryInterface
jQueryMock.elements = [popoverEl] jQueryMock.elements = [popoverEl]
spyOn(Popover.prototype, 'dispose') spyOn(Popover.prototype, 'dispose')
@ -230,14 +230,14 @@ describe('Popover', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return popover instance', () => { it('should return popover instance', () => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-content="https://twitter.com/getbootstrap">BS twitter</a>' fixtureEl.innerHTML = '<a href="#" title="Popover" data-content="https://twitter.com/getbootstrap">BS twitter</a>'
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl) const popover = new Popover(popoverEl)
expect(Popover._getInstance(popoverEl)).toEqual(popover) expect(Popover.getInstance(popoverEl)).toEqual(popover)
}) })
it('should return null when there is no popover instance', () => { it('should return null when there is no popover instance', () => {
@ -245,7 +245,7 @@ describe('Popover', () => {
const popoverEl = fixtureEl.querySelector('a') const popoverEl = fixtureEl.querySelector('a')
expect(Popover._getInstance(popoverEl)).toEqual(null) expect(Popover.getInstance(popoverEl)).toEqual(null)
}) })
}) })
}) })

View File

@ -301,7 +301,7 @@ class ScrollSpy {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
const _config = typeof config === 'object' && config const _config = typeof config === 'object' && config
@ -320,7 +320,7 @@ class ScrollSpy {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -344,11 +344,11 @@ EventHandler.on(window, Event.LOAD_DATA_API, () => {
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = ScrollSpy._jQueryInterface $.fn[NAME] = ScrollSpy.jQueryInterface
$.fn[NAME].Constructor = ScrollSpy $.fn[NAME].Constructor = ScrollSpy
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return ScrollSpy._jQueryInterface return ScrollSpy.jQueryInterface
} }
} }

View File

@ -571,18 +571,18 @@ describe('ScrollSpy', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a scrollspy', () => { it('should create a scrollspy', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.scrollspy = ScrollSpy._jQueryInterface jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.scrollspy.call(jQueryMock) jQueryMock.fn.scrollspy.call(jQueryMock)
expect(ScrollSpy._getInstance(div)).toBeDefined() expect(ScrollSpy.getInstance(div)).toBeDefined()
}) })
it('should not re create a scrollspy', () => { it('should not re create a scrollspy', () => {
@ -591,12 +591,12 @@ describe('ScrollSpy', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const scrollSpy = new ScrollSpy(div) const scrollSpy = new ScrollSpy(div)
jQueryMock.fn.scrollspy = ScrollSpy._jQueryInterface jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.scrollspy.call(jQueryMock) jQueryMock.fn.scrollspy.call(jQueryMock)
expect(ScrollSpy._getInstance(div)).toEqual(scrollSpy) expect(ScrollSpy.getInstance(div)).toEqual(scrollSpy)
}) })
it('should call a scrollspy method', () => { it('should call a scrollspy method', () => {
@ -607,12 +607,12 @@ describe('ScrollSpy', () => {
spyOn(scrollSpy, 'refresh') spyOn(scrollSpy, 'refresh')
jQueryMock.fn.scrollspy = ScrollSpy._jQueryInterface jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.scrollspy.call(jQueryMock, 'refresh') jQueryMock.fn.scrollspy.call(jQueryMock, 'refresh')
expect(ScrollSpy._getInstance(div)).toEqual(scrollSpy) expect(ScrollSpy.getInstance(div)).toEqual(scrollSpy)
expect(scrollSpy.refresh).toHaveBeenCalled() expect(scrollSpy.refresh).toHaveBeenCalled()
}) })
@ -622,7 +622,7 @@ describe('ScrollSpy', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.scrollspy = ScrollSpy._jQueryInterface jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -633,9 +633,9 @@ describe('ScrollSpy', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return null if there is no instance', () => { it('should return null if there is no instance', () => {
expect(ScrollSpy._getInstance(fixtureEl)).toEqual(null) expect(ScrollSpy.getInstance(fixtureEl)).toEqual(null)
}) })
}) })
@ -647,7 +647,7 @@ describe('ScrollSpy', () => {
window.dispatchEvent(createEvent('load')) window.dispatchEvent(createEvent('load'))
expect(ScrollSpy._getInstance(scrollSpyEl)).not.toBeNull() expect(ScrollSpy.getInstance(scrollSpyEl)).not.toBeNull()
}) })
}) })
}) })

View File

@ -210,7 +210,7 @@ class Tab {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
const data = Data.getData(this, DATA_KEY) || new Tab(this) 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) return Data.getData(element, DATA_KEY)
} }
} }
@ -251,11 +251,11 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Tab._jQueryInterface $.fn[NAME] = Tab.jQueryInterface
$.fn[NAME].Constructor = Tab $.fn[NAME].Constructor = Tab
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Tab._jQueryInterface return Tab.jQueryInterface
} }
} }

View File

@ -329,26 +329,26 @@ describe('Tab', () => {
const el = fixtureEl.querySelector('div') const el = fixtureEl.querySelector('div')
const tab = new Tab(fixtureEl.querySelector('div')) const tab = new Tab(fixtureEl.querySelector('div'))
expect(Tab._getInstance(el)).not.toBeNull() expect(Tab.getInstance(el)).not.toBeNull()
tab.dispose() tab.dispose()
expect(Tab._getInstance(el)).toBeNull() expect(Tab.getInstance(el)).toBeNull()
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a tab', () => { it('should create a tab', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.tab = Tab._jQueryInterface jQueryMock.fn.tab = Tab.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tab.call(jQueryMock) jQueryMock.fn.tab.call(jQueryMock)
expect(Tab._getInstance(div)).toBeDefined() expect(Tab.getInstance(div)).toBeDefined()
}) })
it('should not re create a tab', () => { it('should not re create a tab', () => {
@ -357,12 +357,12 @@ describe('Tab', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const tab = new Tab(div) const tab = new Tab(div)
jQueryMock.fn.tab = Tab._jQueryInterface jQueryMock.fn.tab = Tab.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tab.call(jQueryMock) jQueryMock.fn.tab.call(jQueryMock)
expect(Tab._getInstance(div)).toEqual(tab) expect(Tab.getInstance(div)).toEqual(tab)
}) })
it('should call a tab method', () => { it('should call a tab method', () => {
@ -373,12 +373,12 @@ describe('Tab', () => {
spyOn(tab, 'show') spyOn(tab, 'show')
jQueryMock.fn.tab = Tab._jQueryInterface jQueryMock.fn.tab = Tab.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tab.call(jQueryMock, 'show') jQueryMock.fn.tab.call(jQueryMock, 'show')
expect(Tab._getInstance(div)).toEqual(tab) expect(Tab.getInstance(div)).toEqual(tab)
expect(tab.show).toHaveBeenCalled() expect(tab.show).toHaveBeenCalled()
}) })
@ -388,7 +388,7 @@ describe('Tab', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.tab = Tab._jQueryInterface jQueryMock.fn.tab = Tab.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -399,9 +399,9 @@ describe('Tab', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return null if there is no instance', () => { 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', () => { it('should return this instance', () => {
@ -410,7 +410,7 @@ describe('Tab', () => {
const divEl = fixtureEl.querySelector('div') const divEl = fixtureEl.querySelector('div')
const tab = new Tab(divEl) const tab = new Tab(divEl)
expect(Tab._getInstance(divEl)).toEqual(tab) expect(Tab.getInstance(divEl)).toEqual(tab)
}) })
}) })

View File

@ -198,7 +198,7 @@ class Toast {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
const _config = typeof config === 'object' && config const _config = typeof config === 'object' && config
@ -217,7 +217,7 @@ class Toast {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -231,11 +231,11 @@ class Toast {
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Toast._jQueryInterface $.fn[NAME] = Toast.jQueryInterface
$.fn[NAME].Constructor = Toast $.fn[NAME].Constructor = Toast
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Toast._jQueryInterface return Toast.jQueryInterface
} }
} }

View File

@ -253,11 +253,11 @@ describe('Toast', () => {
const toastEl = fixtureEl.querySelector('div') const toastEl = fixtureEl.querySelector('div')
const toast = new Toast(toastEl) const toast = new Toast(toastEl)
expect(Toast._getInstance(toastEl)).toBeDefined() expect(Toast.getInstance(toastEl)).toBeDefined()
toast.dispose() toast.dispose()
expect(Toast._getInstance(toastEl)).toBeNull() expect(Toast.getInstance(toastEl)).toBeNull()
}) })
it('should allow to destroy toast and hide it before that', done => { it('should allow to destroy toast and hide it before that', done => {
@ -273,11 +273,11 @@ describe('Toast', () => {
const toast = new Toast(toastEl) const toast = new Toast(toastEl)
const expected = () => { const expected = () => {
expect(toastEl.classList.contains('show')).toEqual(true) expect(toastEl.classList.contains('show')).toEqual(true)
expect(Toast._getInstance(toastEl)).toBeDefined() expect(Toast.getInstance(toastEl)).toBeDefined()
toast.dispose() toast.dispose()
expect(Toast._getInstance(toastEl)).toBeNull() expect(Toast.getInstance(toastEl)).toBeNull()
expect(toastEl.classList.contains('show')).toEqual(false) expect(toastEl.classList.contains('show')).toEqual(false)
done() done()
@ -291,18 +291,18 @@ describe('Toast', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a toast', () => { it('should create a toast', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.toast = Toast._jQueryInterface jQueryMock.fn.toast = Toast.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.toast.call(jQueryMock) jQueryMock.fn.toast.call(jQueryMock)
expect(Toast._getInstance(div)).toBeDefined() expect(Toast.getInstance(div)).toBeDefined()
}) })
it('should not re create a toast', () => { it('should not re create a toast', () => {
@ -311,12 +311,12 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const toast = new Toast(div) const toast = new Toast(div)
jQueryMock.fn.toast = Toast._jQueryInterface jQueryMock.fn.toast = Toast.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.toast.call(jQueryMock) jQueryMock.fn.toast.call(jQueryMock)
expect(Toast._getInstance(div)).toEqual(toast) expect(Toast.getInstance(div)).toEqual(toast)
}) })
it('should call a toast method', () => { it('should call a toast method', () => {
@ -327,12 +327,12 @@ describe('Toast', () => {
spyOn(toast, 'show') spyOn(toast, 'show')
jQueryMock.fn.toast = Toast._jQueryInterface jQueryMock.fn.toast = Toast.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.toast.call(jQueryMock, 'show') jQueryMock.fn.toast.call(jQueryMock, 'show')
expect(Toast._getInstance(div)).toEqual(toast) expect(Toast.getInstance(div)).toEqual(toast)
expect(toast.show).toHaveBeenCalled() expect(toast.show).toHaveBeenCalled()
}) })
@ -342,7 +342,7 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.toast = Toast._jQueryInterface jQueryMock.fn.toast = Toast.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {
@ -353,14 +353,14 @@ describe('Toast', () => {
}) })
}) })
describe('_getInstance', () => { describe('getInstance', () => {
it('should return collapse instance', () => { it('should return collapse instance', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const toast = new Toast(div) const toast = new Toast(div)
expect(Toast._getInstance(div)).toEqual(toast) expect(Toast.getInstance(div)).toEqual(toast)
}) })
it('should return null when there is no collapse instance', () => { it('should return null when there is no collapse instance', () => {
@ -368,7 +368,7 @@ describe('Toast', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
expect(Toast._getInstance(div)).toEqual(null) expect(Toast.getInstance(div)).toEqual(null)
}) })
}) })
}) })

View File

@ -770,7 +770,7 @@ class Tooltip {
// Static // Static
static _jQueryInterface(config) { static jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = Data.getData(this, DATA_KEY) let data = Data.getData(this, DATA_KEY)
const _config = typeof config === 'object' && config const _config = typeof config === 'object' && config
@ -793,7 +793,7 @@ class Tooltip {
}) })
} }
static _getInstance(element) { static getInstance(element) {
return Data.getData(element, DATA_KEY) return Data.getData(element, DATA_KEY)
} }
} }
@ -807,11 +807,11 @@ class Tooltip {
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof $ !== 'undefined') { if (typeof $ !== 'undefined') {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
$.fn[NAME] = Tooltip._jQueryInterface $.fn[NAME] = Tooltip.jQueryInterface
$.fn[NAME].Constructor = Tooltip $.fn[NAME].Constructor = Tooltip
$.fn[NAME].noConflict = () => { $.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT $.fn[NAME] = JQUERY_NO_CONFLICT
return Tooltip._jQueryInterface return Tooltip.jQueryInterface
} }
} }

View File

@ -266,11 +266,11 @@ describe('Tooltip', () => {
const tooltipEl = fixtureEl.querySelector('a') const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl) const tooltip = new Tooltip(tooltipEl)
expect(Tooltip._getInstance(tooltipEl)).toEqual(tooltip) expect(Tooltip.getInstance(tooltipEl)).toEqual(tooltip)
tooltip.dispose() tooltip.dispose()
expect(Tooltip._getInstance(tooltipEl)).toEqual(null) expect(Tooltip.getInstance(tooltipEl)).toEqual(null)
}) })
it('should destroy a tooltip and remove it from the dom', done => { it('should destroy a tooltip and remove it from the dom', done => {
@ -926,18 +926,18 @@ describe('Tooltip', () => {
}) })
}) })
describe('_jQueryInterface', () => { describe('jQueryInterface', () => {
it('should create a tooltip', () => { it('should create a tooltip', () => {
fixtureEl.innerHTML = '<div></div>' fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
jQueryMock.fn.tooltip = Tooltip._jQueryInterface jQueryMock.fn.tooltip = Tooltip.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tooltip.call(jQueryMock) jQueryMock.fn.tooltip.call(jQueryMock)
expect(Tooltip._getInstance(div)).toBeDefined() expect(Tooltip.getInstance(div)).toBeDefined()
}) })
it('should not re create a tooltip', () => { it('should not re create a tooltip', () => {
@ -946,12 +946,12 @@ describe('Tooltip', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const tooltip = new Tooltip(div) const tooltip = new Tooltip(div)
jQueryMock.fn.tooltip = Tooltip._jQueryInterface jQueryMock.fn.tooltip = Tooltip.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tooltip.call(jQueryMock) jQueryMock.fn.tooltip.call(jQueryMock)
expect(Tooltip._getInstance(div)).toEqual(tooltip) expect(Tooltip.getInstance(div)).toEqual(tooltip)
}) })
it('should call a tooltip method', () => { it('should call a tooltip method', () => {
@ -962,12 +962,12 @@ describe('Tooltip', () => {
spyOn(tooltip, 'show') spyOn(tooltip, 'show')
jQueryMock.fn.tooltip = Tooltip._jQueryInterface jQueryMock.fn.tooltip = Tooltip.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tooltip.call(jQueryMock, 'show') jQueryMock.fn.tooltip.call(jQueryMock, 'show')
expect(Tooltip._getInstance(div)).toEqual(tooltip) expect(Tooltip.getInstance(div)).toEqual(tooltip)
expect(tooltip.show).toHaveBeenCalled() expect(tooltip.show).toHaveBeenCalled()
}) })
@ -978,7 +978,7 @@ describe('Tooltip', () => {
spyOn(Tooltip.prototype, 'dispose') spyOn(Tooltip.prototype, 'dispose')
jQueryMock.fn.tooltip = Tooltip._jQueryInterface jQueryMock.fn.tooltip = Tooltip.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
jQueryMock.fn.tooltip.call(jQueryMock, 'dispose') jQueryMock.fn.tooltip.call(jQueryMock, 'dispose')
@ -992,7 +992,7 @@ describe('Tooltip', () => {
const div = fixtureEl.querySelector('div') const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod' const action = 'undefinedMethod'
jQueryMock.fn.tooltip = Tooltip._jQueryInterface jQueryMock.fn.tooltip = Tooltip.jQueryInterface
jQueryMock.elements = [div] jQueryMock.elements = [div]
try { try {

View File

@ -32,10 +32,10 @@ Currently we're aiming for at least 90% test coverage for our code. To ensure yo
```js ```js
// Synchronous test // Synchronous test
describe('_getInstance', () => { describe('getInstance', () => {
it('should return null if there is no instance', () => { it('should return null if there is no instance', () => {
// Make assertion // Make assertion
expect(Tab._getInstance(fixtureEl)).toEqual(null) expect(Tab.getInstance(fixtureEl)).toEqual(null)
}) })
it('should return this instance', () => { it('should return this instance', () => {
@ -45,7 +45,7 @@ describe('_getInstance', () => {
const tab = new Tab(divEl) const tab = new Tab(divEl)
// Make assertion // Make assertion
expect(Tab._getInstance(divEl)).toEqual(tab) expect(Tab.getInstance(divEl)).toEqual(tab)
}) })
}) })

View File

@ -67,7 +67,7 @@
document.getElementById('btnShowToast').addEventListener('click', function () { document.getElementById('btnShowToast').addEventListener('click', function () {
Array.from(document.querySelectorAll('.toast')) Array.from(document.querySelectorAll('.toast'))
.forEach(function (toastNode) { .forEach(function (toastNode) {
var toast = Toast._getInstance(toastNode) var toast = Toast.getInstance(toastNode)
toast.show() toast.show()
}) })
}) })
@ -75,7 +75,7 @@
document.getElementById('btnHideToast').addEventListener('click', function () { document.getElementById('btnHideToast').addEventListener('click', function () {
Array.from(document.querySelectorAll('.toast')) Array.from(document.querySelectorAll('.toast'))
.forEach(function (toastNode) { .forEach(function (toastNode) {
var toast = Toast._getInstance(toastNode) var toast = Toast.getInstance(toastNode)
toast.hide() toast.hide()
}) })
}) })

View File

@ -133,10 +133,10 @@ This makes an alert listen for click events on descendant elements which have th
</tr> </tr>
<tr> <tr>
<td> <td>
<code>_getInstance</code> <code>getInstance</code>
</td> </td>
<td> <td>
Static method which allows you to get the alert instance associated to a DOM element, you can use it like this: <code>bootstrap.Alert._getInstance(alert)</code> Static method which allows you to get the alert instance associated to a DOM element, you can use it like this: <code>bootstrap.Alert.getInstance(alert)</code>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -144,7 +144,7 @@ This makes an alert listen for click events on descendant elements which have th
{{< highlight js >}} {{< highlight js >}}
var alertNode = document.querySelector('.alert') var alertNode = document.querySelector('.alert')
var alert = bootstrap.Alert._getInstance(alertNode) var alert = bootstrap.Alert.getInstance(alertNode)
alert.close() alert.close()
{{< /highlight >}} {{< /highlight >}}

View File

@ -329,7 +329,7 @@ var carousel = new bootstrap.Carousel(myCarousel, {
<td>Destroys an element's carousel.</td> <td>Destroys an element's carousel.</td>
</tr> </tr>
<tr> <tr>
<td><code>_getInstance</code></td> <td><code>getInstance</code></td>
<td>Static method which allows you to get the carousel instance associated with a DOM element.</td> <td>Static method which allows you to get the carousel instance associated with a DOM element.</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -227,7 +227,7 @@ var bsCollapse = new bootstrap.Collapse(myCollapse, {
<td>Destroys an element's collapse.</td> <td>Destroys an element's collapse.</td>
</tr> </tr>
<tr> <tr>
<td><code>_getInstance</code></td> <td><code>getInstance</code></td>
<td>Static method which allows you to get the collapse instance associated with a DOM element.</td> <td>Static method which allows you to get the collapse instance associated with a DOM element.</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -901,7 +901,7 @@ Note when `boundary` is set to any value other than `'scrollParent'`, the style
</td> </td>
</tr> </tr>
<tr> <tr>
<td><code>_getInstance</code></td> <td><code>getInstance</code></td>
<td> <td>
Static method which allows you to get the dropdown instance associated with a DOM element. Static method which allows you to get the dropdown instance associated with a DOM element.
</td> </td>

View File

@ -820,13 +820,13 @@ Destroys an element's modal.
{{< highlight js >}}myModal.dispose(){{< /highlight >}} {{< highlight js >}}myModal.dispose(){{< /highlight >}}
#### _getInstance #### getInstance
*Static* method which allows you to get the modal instance associated with a DOM element *Static* method which allows you to get the modal instance associated with a DOM element
{{< highlight js >}} {{< highlight js >}}
var myModalEl = document.getElementById('myModal') var myModalEl = document.getElementById('myModal')
var modal = bootstrap.Modal._getInstance(myModalEl) // Returns a Bootstrap modal instance var modal = bootstrap.Modal.getInstance(myModalEl) // Returns a Bootstrap modal instance
{{< /highlight >}} {{< /highlight >}}
### Events ### Events

View File

@ -345,13 +345,13 @@ Updates the position of an element's popover.
{{< highlight js >}}myPopover.update(){{< /highlight >}} {{< highlight js >}}myPopover.update(){{< /highlight >}}
#### _getInstance #### getInstance
*Static* method which allows you to get the popover instance associated with a DOM element *Static* method which allows you to get the popover instance associated with a DOM element
{{< highlight js >}} {{< highlight js >}}
var exampleTriggerEl = document.getElementById('example') var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover._getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
{{< /highlight >}} {{< /highlight >}}
### Events ### Events

View File

@ -75,7 +75,7 @@ var modal = new bootstrap.Modal(myModalEl) // initialized with defaults
var modal = new bootstrap.Modal(myModalEl, { keyboard: false }) // initialized with no keyboard var modal = new bootstrap.Modal(myModalEl, { keyboard: false }) // initialized with no keyboard
{{< /highlight >}} {{< /highlight >}}
If you'd like to get a particular plugin instance, each plugin exposes a `_getInstance` method. In order to retrieve it directly from an element, do this: `bootstrap.Popover._getInstance(myPopoverEl)`. If you'd like to get a particular plugin instance, each plugin exposes a `getInstance` method. In order to retrieve it directly from an element, do this: `bootstrap.Popover.getInstance(myPopoverEl)`.
### Asynchronous functions and transitions ### Asynchronous functions and transitions
@ -95,7 +95,7 @@ In addition a method call on a **transitioning component will be ignored**.
{{< highlight js >}} {{< highlight js >}}
var myCarouselEl = document.getElementById('myCarousel') var myCarouselEl = document.getElementById('myCarousel')
var carousel = bootstrap.Carousel._getInstance(myCarouselEl) // Retrieve a Carousel instance var carousel = bootstrap.Carousel.getInstance(myCarouselEl) // Retrieve a Carousel instance
myCarouselEl.addEventListener('slid.bs.carousel', function (e) { myCarouselEl.addEventListener('slid.bs.carousel', function (e) {
carousel.to('2') // Will slide to the slide 2 as soon as the transition to slide 1 is finished carousel.to('2') // Will slide to the slide 2 as soon as the transition to slide 1 is finished

View File

@ -142,7 +142,7 @@
}) })
clipboard.on('success', function (e) { clipboard.on('success', function (e) {
var tooltipBtn = bootstrap.Tooltip._getInstance(e.trigger) var tooltipBtn = bootstrap.Tooltip.getInstance(e.trigger)
e.trigger.setAttribute('data-original-title', 'Copied!') e.trigger.setAttribute('data-original-title', 'Copied!')
tooltipBtn.show() tooltipBtn.show()
@ -154,7 +154,7 @@
clipboard.on('error', function (e) { clipboard.on('error', function (e) {
var modifierKey = /Mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-' var modifierKey = /Mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
var fallbackMsg = 'Press ' + modifierKey + 'C to copy' var fallbackMsg = 'Press ' + modifierKey + 'C to copy'
var tooltipBtn = bootstrap.Tooltip._getInstance(e.trigger) var tooltipBtn = bootstrap.Tooltip.getInstance(e.trigger)
e.trigger.setAttribute('title', fallbackMsg) e.trigger.setAttribute('title', fallbackMsg)
tooltipBtn._fixTitle() tooltipBtn._fixTitle()