Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for attributes? #13

Closed
geyang opened this issue Oct 29, 2014 · 6 comments
Closed

Support for attributes? #13

geyang opened this issue Oct 29, 2014 · 6 comments

Comments

@geyang
Copy link

geyang commented Oct 29, 2014

Hi @marcelklehr ,

Does vdom-virtualize support attributes? For example, I have alt attribute in my dom that contains crucial information that I can't leave inside the element.

I saw your comment in #1. Is this a problem with virtual-dom or it is something that we can change by patching up this virtualizer?

Thanks!
Ge

@marcelklehr
Copy link
Owner

Alt is supported, since you can access it as a DOM Node property. vdom's
create-element can only set properties afaik, so that e.g. the
disabled attribute must be set using attributes (not via properties)
according to the resource I linked to in #1

@geyang
Copy link
Author

geyang commented Oct 30, 2014

Thanks for your quick reply @marcelklehr! I really want to get this combination to work so your help is really appreciated.

Right now in the following example, the alt="$y$' example does not show up.

What I want to do is:

  1. start with a html string that looks like:

    <p> the variable <span alt="$x$"></span> is blah </p>
    
  2. convert it to vtree,

  3. diff the vtree with the vtree of another html string just like this

    <p> the variable <span alt="$y$"></span> is meh </p>
    
  4. then apply the patch to an element

    <p> the variable <span alt="$x$" randome-attr ></span> is blah </p>
    
  5. and get

    <p> the variable <span alt="$y$" random-attr ></span> is meh </p>
    

The code looks like

                var newView, currentView;
                var newView = vdom.virtualize.fromHTML('<div>' + oldValue + '</div>');
                var currentView = vdom.virtualize.fromHTML('<div>' + newValue + '</div>');
                var patch = vdom.diff(currentView, newView)
                vdom.patch(iElement[0], patch)

but it looks like the patched in the end does not have attributes.

@marcelklehr
Copy link
Owner

Can you post the virtualized vtree? vdom-virtualize should overtake all properties listed here

@hami9x
Copy link

hami9x commented Nov 3, 2014

How is it supposed to handle the MUST_USE_ATTRIBUTE attributes? I tried setting disabled and it doesn't go anywhere, it isn't set to any attribute or property, nowhere to be found in the returned data.
I'm wondering what the "var attrs" in your lib is for, I don't find usage of it anywhere, it hasn't been implemented or something?

@marcelklehr
Copy link
Owner

It doesn't handle MUST_USE_ATTRIBUTE atm, see https://github.com/marcelklehr/vdom-virtualize/blob/master/index.js#L107

@marcelklehr
Copy link
Owner

Attributes are now supported!

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

No branches or pull requests

3 participants