Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base.js « src « js - github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e85dc9be8808a06c19f9828dbe1d330dcb6d5b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { executeAfterTransition } from './util/index'
import Manipulator from './dom/manipulator'

class Base extends HTMLElement {
  constructor(config) {
    super()

    this._config = this._mergeConfigObj(config, this)
  }

  _queueCallback(callback, element, isAnimated = true) {
    executeAfterTransition(callback, element, isAnimated)
  }

  static get DATA_KEY() {
    return `bs.${this.NAME}`
  }

  static get EVENT_KEY() {
    return `.${this.DATA_KEY}`
  }

  _mergeConfigObj(config, element) {
    const jsonConfig = Manipulator.getDataAttribute(element, 'config') // try to parse

    return {
      ...this.constructor.Default,
      ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
      ...Manipulator.getDataAttributes(element),
      ...(typeof config === 'object' ? config : {})
    }
  }
}

export default Base