@maizzle/framework 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -28,36 +28,38 @@ const plugin = () => tree => {
|
|
|
28
28
|
const {selector} = rule
|
|
29
29
|
const prop = get(rule.nodes[0], 'prop')
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
try {
|
|
32
|
+
// If we find the selector in the HTML...
|
|
33
|
+
tree.match(matchHelper(selector), n => {
|
|
34
|
+
const parsedAttrs = parseAttrs(n.attrs)
|
|
35
|
+
const classAttr = get(parsedAttrs, 'class', [])
|
|
36
|
+
const styleAttr = get(parsedAttrs, 'style', {})
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Remove the rule in the <style> tag
|
|
43
|
-
rule.remove()
|
|
44
|
-
}
|
|
38
|
+
// If the class is in the style attribute (inlined), remove it
|
|
39
|
+
if (has(styleAttr, prop)) {
|
|
40
|
+
// Remove the class attribute
|
|
41
|
+
remove(classAttr, s => selector.includes(s))
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
* Remove from <style> selectors that were used to create shorthand declarations
|
|
48
|
-
* like `margin: 0 0 0 16px` (transformed with mergeLonghand when inlining).
|
|
49
|
-
*/
|
|
50
|
-
Object.keys(styleAttr).forEach(key => {
|
|
51
|
-
if (prop && prop.includes(key)) {
|
|
43
|
+
// Remove the rule in the <style> tag
|
|
52
44
|
rule.remove()
|
|
53
|
-
remove(classAttr, s => selector.includes(s))
|
|
54
45
|
}
|
|
55
|
-
})
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Remove from <style> selectors that were used to create shorthand declarations
|
|
49
|
+
* like `margin: 0 0 0 16px` (transformed with mergeLonghand when inlining).
|
|
50
|
+
*/
|
|
51
|
+
Object.keys(styleAttr).forEach(key => {
|
|
52
|
+
if (prop && prop.includes(key)) {
|
|
53
|
+
rule.remove()
|
|
54
|
+
remove(classAttr, s => selector.includes(s))
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
n.attrs = parsedAttrs.compose()
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
return n
|
|
61
|
+
})
|
|
62
|
+
} catch {}
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
node.content = root.toString()
|