Thunberg087 / vue-fragment

a very candide fragment component for Vue.js
http://jsfiddle.net/cdkn5wL3/
670 stars 51 forks source link

`data-` is not passing to fragment #21

Closed Javid-Izadfar closed 5 years ago

Javid-Izadfar commented 5 years ago

I'm using version 1.5.0 and data- properties are not passing to fragments.

example:

<fragment>
      <div data-foo="bar">...</div>
</fragment>

expected result:

<div fragment="123124124" data-foo="bar">...</div>

given result:

<div fragment="123124124">...</div>
Javid-Izadfar commented 5 years ago

I think it's same issue as #20

OmgImAlexis commented 5 years ago

Sounds like these are both related to this line https://github.com/y-nk/vue-fragment/blob/master/src/component.js#L98

OmgImAlexis commented 5 years ago

PING: @y-nk

y-nk commented 5 years ago

@Javid-Izadfar There's a misconception of the expected result.

Given :

<fragment>
      <div data-foo="bar">...</div>
</fragment>

The actual result is (should be, at least) :

<!-- fragment#123124124#head -->
<div data-foo="bar">...</div>
<!-- fragment#123124124#tail -->

without a parent div.

The <div fragment="123124124"> is a temporary placeholder used to gather children and locate point of insertion in the parent node, and is removed after. Therefore, it's useless to try to pass down dom attributes.