lib/hot_module/fragment.rb in hot_module-1.0.0.alpha9 vs lib/hot_module/fragment.rb in hot_module-1.0.0.alpha10
- old
+ new
@@ -1,13 +1,15 @@
# frozen_string_literal: true
module HoTModuLe
class Fragment
- def initialize(fragment, attribute_bindings, html_module:)
+ def initialize(fragment, component)
@fragment = fragment
- @attribute_bindings = attribute_bindings
- @html_module = html_module
+ @component = component
+ @attribute_bindings = component.class.attribute_bindings.each do |attr_def|
+ attr_def.method = component.method(attr_def.method_name)
+ end
end
# NOTE: for some reason, the Nokogiri traverse method yields node children first, then the
# parent node. That doesn't work for our case. We want to go strictly in source order. So this
# is our own implementation of that.
@@ -30,10 +32,11 @@
next if attribute_binding.method.receiver._check_stack(node)
break unless attribute_binding.method.(attribute: attr_node, node: node)
end
rescue Exception => e # rubocop:disable Lint/RescueException
- raise e.class, e.message.lines.first, ["#{@html_module}:#{attr_node}", *e.backtrace]
+ line_segments = [@component.class.html_module, @component.class.line_number_of_node(attr_node)]
+ raise e.class, e.message.lines.first, [line_segments.join(":"), *e.backtrace]
end
end
end
end