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

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/src/util
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2022-04-21 21:41:43 +0300
committerGitHub <noreply@github.com>2022-04-21 21:41:43 +0300
commit584600bda36ac13ea325617783216d6c6a331c08 (patch)
tree053f97d3e8401864aca9c0b8e180a3d2c089b4be /js/src/util
parent01cffa682249965eafa581058dd993853d82b3c4 (diff)
Manipulator: Add JSON parse support (#35077)
Support parsing JSON from each component's main element using the `data-bs-config` attribute. The `bs-config` attribute will be reserved and omitted during `getDataAttributes` parsing. With this commit, every component, will create its config object, using: * defaults * data-bs-config * the rest of data attributes * configuration object given during instance initialization Co-authored-by: XhmikosR <xhmikosr@gmail.com> Co-authored-by: Mark Otto <markd.otto@gmail.com> Co-authored-by: Mark Otto <markdotto@gmail.com>
Diffstat (limited to 'js/src/util')
-rw-r--r--js/src/util/config.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/js/src/util/config.js b/js/src/util/config.js
index 19d02955dd..f6c194276b 100644
--- a/js/src/util/config.js
+++ b/js/src/util/config.js
@@ -38,8 +38,11 @@ class Config {
}
_mergeConfigObj(config, element) {
+ const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {} // try to parse
+
return {
...this.constructor.Default,
+ ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
...(typeof config === 'object' ? config : {})
}