mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: Helper method to return an attributes literal value if it has a literal value
This commit is contained in:
parent
dfdbf8b377
commit
07e513c6ff
@ -180,6 +180,14 @@ class HtmlAttribute extends Node {
|
|||||||
walk(walker) {
|
walk(walker) {
|
||||||
this.value = walker.walk(this.value);
|
this.value = walker.walk(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get literalValue() {
|
||||||
|
if (this.isLiteralValue()) {
|
||||||
|
return this.value.value;
|
||||||
|
} else {
|
||||||
|
throw new Error('Attribute value is not a literal value. Actual: ' + JSON.stringify(this.value, null, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlAttribute.isHtmlAttribute = function(attr) {
|
HtmlAttribute.isHtmlAttribute = function(attr) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user