Closed
Description
For example this test case will fail:
it 'Looks up components in nested namespaces correctly' do
mount 'Foo::Bar::Zoom' do
module Foo
module Bar
class Zoom < HyperComponent
render do
Wham()
end
end
end
end
module Wham
end
module Foo
module Bar
class Wham < HyperComponent
render(DIV) do
"found me!"
end
end
end
end
end
expect(page).to have_content('found me!')
end
The problem is in the lookup_const
method in the Tags
module the const_defined?
and const_get
calls must include the second false
parameter to prevent looking up the ancestor tree.
You can patch it like this:
module Hyperstack
module Internal
module Component
module Tags
def lookup_const(name)
return nil unless name =~ /^[A-Z]/
scopes = self.class.name.to_s.split('::').inject([Object]) do |nesting, next_const|
nesting + [nesting.last.const_get(next_const)]
end.reverse
scope = scopes.detect { |s| s.const_defined?(name, false) }
scope.const_get(name, false) if scope
end
end
end
end
end
For the hyperloop legacy branch the same method is in
module React
module Component
module Tags
def lookup_const(name)
...
end
end
end
end
However this has a knock on effect that breaks hyper-model's INPUT tag redefinition. In that method redefinition the newly defined tag constants are made on the Tag module scope (incorrectly) and this bug allowed that to work. So that has to also be fixed, i.e. the new tags need to be defined against Object.