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

Changing :options to attributes makes them appear in DOM #556

Closed
xPaw opened this issue Mar 4, 2019 · 11 comments
Closed

Changing :options to attributes makes them appear in DOM #556

xPaw opened this issue Mar 4, 2019 · 11 comments

Comments

@xPaw
Copy link

xPaw commented Mar 4, 2019

For example, if you have this:

<Draggable
	:list="networks"
	:disabled="isSortingEnabled"
	handle=".lobby"
	draggable=".network"
	ghost-class="network-placeholder"
	group="networks"
	class="networks"

And looking at devtools, the html rendered ends up being this:
<div handle=".lobby" draggable="true" ghost-class="network-placeholder" group="networks" class="networks">

It doesn't sound like a particularly good idea to do this, perhaps valid options should be skipped from DOM if possible?

@David-Desmaisons
Copy link
Member

I will correct

@David-Desmaisons
Copy link
Member

Corrected in version 2.19,1

@courcelan
Copy link

@David-Desmaisons Hi, any way to apply some $attrs to the created element? I use a couple of custom attributes in development, o-base specifically in this case, and this doesn't get applied to the created element like it used to. I see above that the ":options to attributes" was corrected, but now it takes all those attributes and holds on to them.

@David-Desmaisons
Copy link
Member

You are correct @courcelan , with this correction, your scenario will be broken. Can you explain better why you pass attributes to the root element?

@courcelan
Copy link

Sure! The root element is the containing element and is needed for flex/grid/padding/etc. We use a variation of functional css and a system of attributes mapped to various media queries rather than overload the class attribute with what could be extremely lengthy declaration.

I’ve gotten around the issue by making the root element very “dumb” and is in another containing element that uses the appropriate attributes. However this does call for extra unnecessary markup that would be better served by allowing general attributes to be placed on the root element.

Thanks!

@David-Desmaisons
Copy link
Member

You cab make the root element and pass props to it using componnetData props (see for example https://sortablejs.github.io/Vue.Draggable/#/third-party)
THis component will use its props to set attribute on the rrot component.
This solution should address your scenario.

@jbayona89
Copy link

I think this may have broken the id prop that is not getting set <Draggable
:list="networks"
:disabled="isSortingEnabled"
handle=".lobby"
draggable=".network"
ghost-class="network-placeholder"
group="networks"
class="networks"
id="myId"

the id="myId" dissapears from the object

@David-Desmaisons
Copy link
Member

@jbayona89 you are correct, could you create a dedicated issue for id attribute, please?

@jbayona89
Copy link

@David-Desmaisons Already done, #566

@David-Desmaisons
Copy link
Member

@courcelan starting with version 2.19,2 id and attribute starting with "data-" will be copied as attribute to the root element. This should address your scenario provided you named them "data-something"

@courcelan
Copy link

@David-Desmaisons great. thanks!

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

4 participants