Skip to content

hypercomponent class not inheriting correctly #60

Closed

Description

@catmando

This spec fails:

  it "can create an inherited component's  insert_element alias" do
    mount 'Tester' do
      module Container
        class Base < HyperComponent
          before_mount do
            @_instance_data = []
          end
        end
        class Thing < Base
          before_mount do
            @_instance_data << "works!"
          end
          render { @_instance_data.join(" ") }
        end
      end
      class Tester < HyperComponent
        render { Container::Thing() }
      end
    end
    expect(page).to have_content('works!')
  end

No method Thing for Container!

Activity

  1. catmando commented on Nov 15, 2018

    @catmando
    ContributorAuthor

    The fix for this relies on the render macro calling Tags.included(self) which registers the class name in the parent.

    So we need to deprecate all use of def render.

  2. added a commit that references this issue on Nov 15, 2018
    c1ca596
  3. catmando commented on Nov 15, 2018

    @catmando
    ContributorAuthor

    This is closed pending release.

    Be aware that component class inheritance will not work correctly unless using the render macro. If you want to get rid of the warning temporarily and work around the inheritance problem do this in your base component class:

    class LegacyBaseClass
       def self.inherited(base) 
          base.include Hyperstack::Component::Base
        end
        def self.allow_deprecated_render_definition?
           true
        end
        ...
    end

    In Legacy Hyperloop the Hyperloop Component base class defined the inherited method as shown above. But in Hyperstack we don't want to force use of a base class prefering module includes instead. However some features, notably the ability to reference the component's insert_element method by using the class name followed by parenthesis (i.e. Foo::Bar()) depends on knowing when the component class is defined.

    Since every runnable component must have a render callback, we use the callback definition as a hook to add the class method definition.

  4. barriehadfield commented on Nov 16, 2018

    @barriehadfield
    Contributor

    @catmando all of the docs and examples use render do already

  5. added 3 commits that reference this issue on Sep 2, 2026
    ab0693e
    28f9809
    1d82a0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions