mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #386 - Allow regular expression for an HTML attribute value
This commit is contained in:
parent
a35e6bdbc3
commit
adb7fe1623
@ -121,7 +121,13 @@ module.exports = function generateCode(node, codegen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node.isLiteralValue()) {
|
if (node.isLiteralValue()) {
|
||||||
return builder.htmlLiteral(attr(name, value.value));
|
let literalValue = value.value;
|
||||||
|
|
||||||
|
if (literalValue instanceof RegExp) {
|
||||||
|
literalValue = literalValue.source;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.htmlLiteral(attr(name, literalValue));
|
||||||
} else if (value != null) {
|
} else if (value != null) {
|
||||||
return generateCodeForExpressionAttr(name, value, escape, codegen);
|
return generateCodeForExpressionAttr(name, value, escape, codegen);
|
||||||
} else if (argument) {
|
} else if (argument) {
|
||||||
|
|||||||
1
test/autotests/render/pattern-attr/expected.html
Normal file
1
test/autotests/render/pattern-attr/expected.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<input type="text" pattern="\w{2,20}">
|
||||||
1
test/autotests/render/pattern-attr/template.marko
Normal file
1
test/autotests/render/pattern-attr/template.marko
Normal file
@ -0,0 +1 @@
|
|||||||
|
<input type="text" pattern=/\w{2,20}/ />
|
||||||
1
test/autotests/render/pattern-attr/test.js
Normal file
1
test/autotests/render/pattern-attr/test.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
Loading…
x
Reference in New Issue
Block a user