mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #198 - Marko v3: Replace <div attrs(myAttrs)> with <div ${myAttrs}>
This commit is contained in:
parent
f47bfe9da3
commit
9dbb77870f
@ -213,6 +213,10 @@ class CompileContext {
|
||||
// Validate the attributes
|
||||
attributes.forEach((attr) => {
|
||||
let attrName = attr.name;
|
||||
if (!attrName) {
|
||||
// Attribute will be name for placeholder attributes. For example: <div ${data.myAttrs}>
|
||||
return;
|
||||
}
|
||||
let attrDef = taglibLookup.getAttribute(tagName, attrName);
|
||||
if (!attrDef) {
|
||||
if (tagDef) {
|
||||
|
||||
@ -149,6 +149,10 @@ class HtmlAttribute extends Node {
|
||||
let value = this.value;
|
||||
let argument = this.argument;
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isLiteralValue()) {
|
||||
var literalValue = value.value;
|
||||
if (typeof literalValue === 'boolean' || literalValue === '') {
|
||||
|
||||
@ -31,7 +31,10 @@ class HtmlAttributeCollection {
|
||||
}
|
||||
}
|
||||
|
||||
this.lookup[name.toLowerCase()] = newAttr;
|
||||
if (name) {
|
||||
this.lookup[name.toLowerCase()] = newAttr;
|
||||
}
|
||||
|
||||
this.all.push(newAttr);
|
||||
}
|
||||
|
||||
|
||||
@ -69,15 +69,6 @@ var coreAttrHandlers = [
|
||||
el.setBodyOnlyIf(condition);
|
||||
}
|
||||
],
|
||||
[
|
||||
'attrs', function(attr, node) {
|
||||
if (!node.addDynamicAttributes) {
|
||||
node.addError('Node does not support the "attrs" attribute');
|
||||
} else {
|
||||
node.addDynamicAttributes(attr.value);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'marko-preserve-whitespace', function(attr, node) {
|
||||
node.setPreserveWhitespace(true);
|
||||
@ -116,6 +107,14 @@ module.exports = function transform(el, context) {
|
||||
|
||||
el.forEachAttribute((attr) => {
|
||||
let attrName = attr.name;
|
||||
if (!attrName) {
|
||||
if (!node.addDynamicAttributes) {
|
||||
node.addError('Node does not support the "attrs" attribute');
|
||||
} else {
|
||||
node.addDynamicAttributes(attr.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var attrTransformerFunc = attributeTransformers[attrName];
|
||||
if (attrTransformerFunc) {
|
||||
if (!attributeTransfomer) {
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
<div attrs=data.myAttrs data-encoding='"hello"'>
|
||||
<div ${data.myAttrs} data-encoding='"hello"'>
|
||||
Hello World!
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user