AFASSoftware / maquette

Pure and simple virtual DOM library

Home Page:https://maquettejs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Is it possible to create a virtual dom based on an existing dom element

soyuka opened this issue · comments

I was wondering if there is a way to create a virtual hyperscript node from an existing element. For example:

h(document.getElementById('exists'), {properties}, [childrens])

I found that I could init a node without using h() by returning the expected result, for example:

    {
      vnodeSelector: 'input',
      properties: {
        type: 'text',
      },
      text: undefined,
      domNode: document.getElementById('exists')
    },

I thought that by specifying the domNode it won't be appended, but it's anyway.

This would be helpfull if you want to add features to an existing dom element, but maybe it's out of scope. Thanks.

Maybe related to #53

You could use the Projector.merge method, see http://maquettejs.org/docs/typedoc/interfaces/_maquette_.projector.html#merge).

Is this what you need?