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
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-12-10 19:18:18 +0300
committerGitHub <noreply@github.com>2021-12-10 19:18:18 +0300
commit886b940796b3595a03b44230ca8b78197c5ee1c5 (patch)
tree6b37d0208ae9fd9816e052572ab3496095cc88b6 /js/src/util/template-factory.js
parent68f226750db03bc26ed5ead6bb074804a4f63853 (diff)
Extract Component config functionality to a separate class (#33872)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/util/template-factory.js')
-rw-r--r--js/src/util/template-factory.js31
1 files changed, 15 insertions, 16 deletions
diff --git a/js/src/util/template-factory.js b/js/src/util/template-factory.js
index a9cee1086c..8a8d4da798 100644
--- a/js/src/util/template-factory.js
+++ b/js/src/util/template-factory.js
@@ -6,8 +6,9 @@
*/
import { DefaultAllowlist, sanitizeHtml } from './sanitizer'
-import { getElement, isElement, typeCheckConfig } from '../util/index'
+import { getElement, isElement } from '../util/index'
import SelectorEngine from '../dom/selector-engine'
+import Config from './config'
/**
* Constants
@@ -44,20 +45,25 @@ const DefaultContentType = {
* Class definition
*/
-class TemplateFactory {
+class TemplateFactory extends Config {
constructor(config) {
+ super()
this._config = this._getConfig(config)
}
// Getters
- static get NAME() {
- return NAME
- }
-
static get Default() {
return Default
}
+ static get DefaultType() {
+ return DefaultType
+ }
+
+ static get NAME() {
+ return NAME
+ }
+
// Public
getContent() {
return Object.values(this._config.content)
@@ -94,21 +100,14 @@ class TemplateFactory {
}
// Private
- _getConfig(config) {
- config = {
- ...Default,
- ...(typeof config === 'object' ? config : {})
- }
-
- typeCheckConfig(NAME, config, DefaultType)
+ _typeCheckConfig(config) {
+ super._typeCheckConfig(config)
this._checkContent(config.content)
-
- return config
}
_checkContent(arg) {
for (const [selector, content] of Object.entries(arg)) {
- typeCheckConfig(NAME, { selector, entry: content }, DefaultContentType)
+ super._typeCheckConfig({ selector, entry: content }, DefaultContentType)
}
}