Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

allow built in tags to be redefined #269

Closed
catmando opened this issue Jul 19, 2018 · 1 comment
Closed

allow built in tags to be redefined #269

catmando opened this issue Jul 19, 2018 · 1 comment

Comments

@catmando
Copy link
Contributor

catmando commented Jul 19, 2018

For example Hypermesh needs to add some capability to INPUT tags.

Currently builtin tags are treated as special cases. Instead they should just be components like everything else, so that the render, and and hooks can be redefined.

catmando added a commit that referenced this issue Jul 24, 2018
catmando added a commit that referenced this issue Jul 24, 2018
catmando added a commit that referenced this issue Jul 25, 2018
@catmando
Copy link
Contributor Author

catmando commented Jul 25, 2018

This can be done without general performance impact (unlike removed solution) as follows:

      # first remove current definitions from React::Component::Tags
      React::Component::Tags.remove_method :DIV
      React::Component::Tags.send(:remove_const, :DIV)
      # now you can freely redefine
      class React::Component::Tags::DIV < Hyperloop::Component
        others :opts
        render do
          # default behavior is
          # present ..tag-name.., params.opts, &children
          # for example to add data-render-time to every div:
          present :div, params.opts, data: {render_time:  Time.now}, &children
        end
      end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant