fix null on if

This commit is contained in:
Tobe O 2019-01-31 16:37:10 -05:00
parent b4a63ac701
commit e74bcd0860
2 changed files with 8 additions and 2 deletions

View file

@ -1,3 +1,7 @@
# 2.1.0
* Fixed handling of `if` in non-strict mode.
*
# 2.0.1 # 2.0.1
* Fixed bug where the `textarea` name check would never return `true`. * Fixed bug where the `textarea` name check would never return `true`.

View file

@ -211,12 +211,14 @@ class Renderer {
Element element, CodeBuffer buffer, SymbolTable scope, bool html5) { Element element, CodeBuffer buffer, SymbolTable scope, bool html5) {
var attribute = element.attributes.singleWhere((a) => a.name == 'if'); var attribute = element.attributes.singleWhere((a) => a.name == 'if');
var v = attribute.value.compute(scope) as bool; var vv = attribute.value.compute(scope);
if (scope.resolve('!strict!')?.value == false) { if (scope.resolve('!strict!')?.value == false) {
v = v == true; vv = vv == true;
} }
var v = vv as bool;
if (!v) return; if (!v) return;
var otherAttributes = element.attributes.where((a) => a.name != 'if'); var otherAttributes = element.attributes.where((a) => a.name != 'if');