Sha256: 50ad2dd317a5260b908e75f9ec314b8092988b6ebc168b4dddd234ef82ddc704

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  module Presenter
    class Renderer
      module Behavior
        # @api private
        module CleanupUnboundBindings
          extend Support::Extension

          apply_extension do
            attach do |presenter|
              unless Pakyow.env?(:prototype)
                # Cleanup unbound bindings. We don't do this in prototype mode because it's important
                # for the prototype to be complete, showing everything to the designer.
                #
                presenter.render node: -> {
                  object.find_significant_nodes(:binding, descend: true).map { |node|
                    View.from_object(node)
                  }
                }, priority: :low do
                  # We check that the node is still labeled as a binding in case the node was replaced
                  # during a previous transformation with a node that isn't a binding.
                  #
                  unless !view.object.labeled?(:binding) || view.object.labeled?(:bound) || view.object.labeled?(:failed) || view.object.label(:version) == :empty
                    remove
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-presenter-1.0.6 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.5 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.4 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.3 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb
pakyow-presenter-1.0.2 lib/pakyow/presenter/renderer/behavior/cleanup_unbound_bindings.rb