lib/heartml/server_effects.rb in heartml-1.0.0.beta10 vs lib/heartml/server_effects.rb in heartml-1.0.0.beta11

- old
+ new

@@ -54,33 +54,38 @@ node.add_class k.to_s if v end } directive :attribute, ->(_, node, name, value) { - node[name] = value + node[name] = value if name.match?(%r{^aria[A-Z-]}) || value } end end def _server_effect_binding(attribute:, node:) _iso_effect_binding(attribute:, node:) - node.remove_attribute "host-effect" + node.remove_attribute "host-lazy-effect" end def _iso_effect_binding(attribute:, node:) # rubocop:disable Metrics syntax = attribute.value statements = syntax.split(";").map(&:strip) - statements.each do |statement| + statements.each do |statement| # rubocop:disable Metrics if statement.start_with?("@") # property assignment expression = statement.split("=").map(&:strip) expression[0] = expression[0][1..] value = send(expression[1][1..]) + attribute_value = if expression[0].match?(%r{^aria[A-Z-]}) && [true, false].include?(value) + value + else + value_to_attribute(value) + end - node.send("#{expression[0]}=", value_to_attribute(value)) + node.send("#{expression[0]}=", attribute_value) unless attribute_value.nil? elsif statement.start_with?("$") # directive directive_name, args_str = statement.strip.match(/(.*)\((.*)\)/).captures arg_strs = args_str.split(",").map(&:strip) arg_strs.unshift("@") @@ -99,10 +104,10 @@ args = arg_strs.map { _convert_effect_arg_to_value _1, node } send(method_name.strip, *args) end - attribute.name = "host-effect" + attribute.name = "host-lazy-effect" end end def _convert_effect_arg_to_value(arg_str, node) return node if arg_str == "@"