nuejs / nue

A web framework for UX developers
https://nuejs.org
MIT License
6.04k stars 179 forks source link

top tag as another component #188

Open caesar1shi opened 7 months ago

caesar1shi commented 7 months ago
<div @name="people">
  <div>name: { name }</div>
  <div>info: { description() }</div>

  <script>
    description() {
      return `${ this.name } is a ${ this.identity }`;
    }
  </script>
</div>

<people @name="student">
  <script>
    identity = "student"
  </script>
</people>

<student name="John"></student>

The above code is currently ineffective, when top tag is another component.

To fix it, you only need to swap the positions of walk(root) and wrap.replaceWith(root) in the function mount, as shown in the figure.

CJC1C5}ZF`)N`726M1X$~%U

tipiirai commented 7 months ago

Nice! I'm hoping to have an automated test suite for client-side components. After that, changes like this would feel safe to merge. However, that would be a low-priority thing because of the current development focus