lib/hyperloop/d3/mixin.rb in hyper-d3-1.0.0.lap24 vs lib/hyperloop/d3/mixin.rb in hyper-d3-1.0.0.lap25

- old
+ new

@@ -10,14 +10,21 @@ def _set_dom_node(dom_node) @_dom_node = dom_node end + def selection + if @_dom_node + selection = ::D3.select(@_dom_node) + else + raise "No DOM Node available for D3::Selection" + end + end + def self.before_unmount_with_selection(&block) before_unmount do if @_dom_node && block - selection = ::D3.select(@_dom_node) block.call(selection, @_data) end end end @@ -37,19 +44,17 @@ false end after_mount do if @_dom_node && @_d3_render_block - selection = ::D3.select(@_dom_node) @_d3_render_block.call(selection, @_data) end end before_receive_props do |new_props| if new_props[:data] != @_data @_data = new_props[:data] if @_dom_node && @_d3_render_block - selection = ::D3.select(@_dom_node) @_d3_render_block.call(selection, @_data) end end end end \ No newline at end of file