fastjs-team / core

Fastjs is a useful, lightweight JavaScript library for any types of project.
https://fastjs.dev
MIT License
341 stars 37 forks source link

Error when push a FastjsDom into parent container #100

Closed xiaodong2008 closed 2 months ago

xiaodong2008 commented 2 months ago

What is the current behavior?

jsfast.js?v=e4690689:541 Uncaught TypeError: el.appendChild is not a function
    at _FastjsDom.push (jsfast.js?v=e4690689:541:22)
    at newStar (App.vue:44:12)
    at Proxy.mounted (App.vue:54:5)
    at chunk-PEY6ZZ6F.js?v=e4690689:4324:88
    at callWithErrorHandling (chunk-PEY6ZZ6F.js?v=e4690689:1659:19)
    at callWithAsyncErrorHandling (chunk-PEY6ZZ6F.js?v=e4690689:1666:17)
    at hook.__weh.hook.__weh (chunk-PEY6ZZ6F.js?v=e4690689:4304:19)
    at flushPostFlushCbs (chunk-PEY6ZZ6F.js?v=e4690689:1841:41)
    at render2 (chunk-PEY6ZZ6F.js?v=e4690689:8132:7)
    at mount (chunk-PEY6ZZ6F.js?v=e4690689:5375:13)

What is the expected behavior?

It should push span into .background

Steps to reproduce the problem

Code:

dom
          .newEl("span", {
            class: "star",
            css: {
              left: rand(0, 100) + "vw",
              top: rand(0, 100) + "vh",
              transform: `scale(${rand(0, 150) / 100 + 0.5})`,
            },
          })
          .push(dom.select(".background")).el
          .then((star) => {
            star.addClass("show").then(() => {
              star.addClass("hide").then(() => {
                star.remove();
              }, 1000);
            }, rand(3000, 15000))
          }, 10)
          .then(newStar, rand(100, 2000))

System Info

Version: `v1.0.0-alpha.6`

Any additional comments?

No response

Confirmations

xiaodong2008 commented 2 months ago

Reproduce: https://stackblitz.com/edit/fastjs-reproduce-jqpuxd?file=src%2Fmain.ts It seems that it only throws an error when giving a FastjsDomList

xiaodong2008 commented 2 months ago

Fixed: 41d8cfa82e272ba6f3deb0b4b79a51ffed1f6a96