aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-07-23 09:57:04 +0200
committerache <ache@ache.one>2018-07-23 10:02:22 +0200
commitfb87f6f6b74695b5369c9ac55775f45ef4d0fe1d (patch)
tree39e9ffff1419ccf51367b7641b90606d25b9a1c8
parentfollow linter presets (diff)
update of the dist file
-rw-r--r--dist/index.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/dist/index.js b/dist/index.js
index c3b4a9e..a929d0e 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -12,11 +12,27 @@ var nothingHappend = {
eaten: ''
};
+var defaultConfig = {
+ defaultValue: function defaultValue() {
+ return undefined;
+ } // It's a function
+};
+
// Main function
-function parse(value, indexNext) {
+function parse(value, indexNext, userConfig) {
var letsEat = '';
var stopOnBrace = false;
var errorDetected = false;
+ var config = Object.assign({}, defaultConfig, userConfig);
+
+ // Make defaultValue a function if it isn't
+ if (typeof config.defaultValue !== 'function') {
+ var defaultValue = config.defaultValue;
+
+ config.defaultValue = function () {
+ return defaultValue;
+ };
+ }
var prop = { key: undefined /* {} */, class: undefined /* [] */, id: undefined };
@@ -34,7 +50,7 @@ function parse(value, indexNext) {
* .azcv <- class
* #poi <- id
* dfgh=zert <- key
- * jkj <- this is also a key but with a undefined value
+ * jkj <- this is also a key but with a user defined value (default is undefined)
* jkj= <- this is also a key but with a empty value
*/
var type = void 0;
@@ -146,7 +162,13 @@ function parse(value, indexNext) {
return nothingHappend;
}
if (labelFirst !== 'id' && labelFirst !== 'class') {
- prop[labelFirst] = labelSecond;
+ if (labelSecond === undefined) {
+ // Here, we have a attribute without value
+ // so it's user defined
+ prop[labelFirst] = config.defaultValue(labelFirst);
+ } else {
+ prop[labelFirst] = labelSecond;
+ }
}
break;
default: