aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-01-03 09:15:14 +0100
committerache <ache@ache.one>2019-01-03 09:15:14 +0100
commitef1a764b1efca373fb62e14f1388c6dc0fbd631f (patch)
tree58cd955aa923280a5d6d8567802c22dd02e89387
parentNew tests about id property (diff)
Update id property priority
-rw-r--r--dist/index.js16
-rw-r--r--src/index.js13
2 files changed, 27 insertions, 2 deletions
diff --git a/dist/index.js b/dist/index.js
index 8ae7b4f..ab96cab 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -157,11 +157,19 @@ function parse(value, indexNext, userConfig) {
}
};
+ var idSetByKey = false;
+
var addAttribute = function addAttribute() {
switch (type) {
case 'id':
// ID
- prop.id = prop.id || labelFirst;
+ if (idSetByKey) {
+ prop.id = labelFirst;
+ idSetByKey = false;
+ } else {
+ prop.id = prop.id || labelFirst;
+ }
+
break;
case 'class':
@@ -188,6 +196,12 @@ function parse(value, indexNext, userConfig) {
} else {
prop[labelFirst] = labelFirst === 'class' ? [labelSecond] : labelSecond;
}
+
+ if (labelFirst === 'id') {
+ idSetByKey = true;
+ }
+ } else if (labelFirst === 'class' && Boolean(labelSecond)) {
+ prop.class.push(labelSecond);
}
break;
diff --git a/src/index.js b/src/index.js
index fc7a02a..3983260 100644
--- a/src/index.js
+++ b/src/index.js
@@ -150,10 +150,16 @@ function parse(value, indexNext, userConfig) {
}
};
+ let idSetByKey = false;
const addAttribute = () => {
switch (type) {
case 'id': // ID
- prop.id = prop.id || labelFirst;
+ if (idSetByKey) {
+ prop.id = labelFirst;
+ idSetByKey = false;
+ } else {
+ prop.id = prop.id || labelFirst;
+ }
break;
case 'class':
if (!prop.class) {
@@ -176,6 +182,11 @@ function parse(value, indexNext, userConfig) {
} else {
prop[labelFirst] = labelFirst === 'class' ? [labelSecond] : labelSecond;
}
+ if (labelFirst === 'id') {
+ idSetByKey = true;
+ }
+ } else if (labelFirst === 'class' && Boolean(labelSecond)) {
+ prop.class.push(labelSecond);
}
break;
default: