babel-plugin-mithril-add-data-attribute
Advanced tools
Comparing version
@@ -216,3 +216,3 @@ "use strict"; | ||
}); | ||
path.skip(); // only add attr to first m-call in an expession | ||
path.stop(); // only add attr to first m-call in an expession | ||
}, | ||
@@ -245,4 +245,3 @@ | ||
}) => { | ||
console.log("Ö -- ObjectExpression"); // insert into object | ||
console.log("Ö -- ObjectExpression"); | ||
const hasDataAttribute = path.node.properties.find(property => t.isObjectProperty(property) && t.isStringLiteral(property.key, { | ||
@@ -253,2 +252,3 @@ value: DATA_ATTRIBUTE | ||
if (hasDataAttribute) { | ||
path.stop(); | ||
return; | ||
@@ -258,3 +258,3 @@ } | ||
path.node.properties.push(createObjectProperties(name)); | ||
path.stop(); | ||
path.skip(); | ||
}, | ||
@@ -388,11 +388,46 @@ Identifier: (path, state) => { | ||
const test = testTransform(` | ||
export default class extends m.Component { | ||
view() { | ||
return m("div"); | ||
} | ||
} | ||
`, {}, { | ||
filename | ||
}); | ||
const Button = { | ||
oncreate(vnode) { | ||
if (vnode.attrs.hoverLabel) { | ||
this.tooltip = createHoverTooltip(vnode); | ||
} | ||
}, | ||
onupdate(vnode) { | ||
if (vnode.attrs.hoverLabel && !this.tooltip) { | ||
this.tooltip = createHoverTooltip(vnode); | ||
} | ||
if (this.tooltip) { | ||
const tooltip = typeof vnode.attrs.hoverLabel === "string" ? vnode.attrs.hoverLabel : null; | ||
if (vnode.attrs.disabled || !tooltip) { | ||
this.tooltip.disable(); | ||
} else if (tooltip) { | ||
this.tooltip.setContent(tooltip); | ||
this.tooltip.enable(); | ||
} | ||
} | ||
}, | ||
onbeforeremove() { | ||
if (this.tooltip) { | ||
this.tooltip.destroy(); | ||
} | ||
}, | ||
view: (vnode) => { | ||
const { type = "button", onclick, disabled, label, ...attrs } = vnode.attrs; | ||
return m( | ||
"div", | ||
{ | ||
...attrs, | ||
type, | ||
class: getClassName(vnode.attrs), | ||
roffe: "leffe", | ||
onclick: disabled ? undefined : onclick, | ||
disabled: disabled ? "disabled" : undefined, | ||
}, | ||
label | ||
); | ||
}, | ||
}; | ||
`); | ||
test; | ||
console.log(test); |
@@ -227,2 +227,3 @@ "use strict"; | ||
if (hasDataAttribute) { | ||
path.stop(); | ||
return; | ||
@@ -229,0 +230,0 @@ } |
{ | ||
"name": "babel-plugin-mithril-add-data-attribute", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"description": "Babel plugin adds attributes to m() components - intended for development. Helps debug - find your components in a large repo. Adds component name and file to component data attributes which will be visible in the generated HTML.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21631
4.63%614
6.23%0
-100%