Skip to content

support static tbody tr td elements #1268

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

Closed
wants to merge 4 commits into from
Closed

support static tbody tr td elements #1268

wants to merge 4 commits into from

Conversation

shengxinjing
Copy link
Contributor

@shengxinjing shengxinjing commented May 31, 2020

Direct set div.innerHTML in insertStaticContent will result in lost rendering of table tags such as tr,td, we need to wrap the right table elements before innerHTML

template example

template code
vue bug project

reder a simple table in App.vue

<template>
<table>
  <tr>
    <td class="col-md-1"> vue3 </td>
    <td class="col-md-1"> vue3 </td>
    <td class="col-md-1"> vue3 </td>
    <td class="col-md-1"> vue3 </td>
    <td class="col-md-1"> vue3 </td>
  </tr>
</table>
</template>

<script>
export default {
  
}
</script>

<style>
.col-md-1{
  border:1px solid black;
}
</style>

but only render the text

<table> vue3  vue3  vue3  vue3  vue3 </table>

Bug Reason

const div = document.createElement('div')
div.innerHTML = '<tr><td class=\"col-md-1\"> vue3 </td><td class=\"col-md-1\"> vue3 </td><td class=\"col-md-1\"> vue3 </td><td class=\"col-md-1\"> vue3 </td><td class=\"col-md-1\"> vue3 </td></tr>'
console.log(div.innerHTML)
VM379:3  vue3  vue3  vue3  vue3  vue3 

@underfin
Copy link
Member

underfin commented May 31, 2020

Thanks for this pr. But we can't warp some tags with user provider,like this case.And if we do it, should process it in complier time instead of runtime.
In fact,we should avoid stringfy some node which cause error when use innnerHtml , eg. table related nodes.

@shengxinjing
Copy link
Contributor Author

thanks for reply , aviod compiler transform table node to staticNode maybe better,
I'll try to submit the code again later. thanks

@underfin
Copy link
Member

underfin commented May 31, 2020

Here has an solution for this problem.#1230 track here.

@shengxinjing
Copy link
Contributor Author

shengxinjing commented May 31, 2020

compiler is better for code organization
maybe runtime is better for perf

@shengxinjing
Copy link
Contributor Author

compiler is better for code organization
maybe runtimer is better for perf

No.Because we also consider ssr.If we wrap some tags only in runtime-dom.It will cause hydration error.

we wrap table element and get firstChild by depth for return ,we also has same dom tree in ssr

@underfin
Copy link
Member

Yeah.I realizi it.So call back it.

@shengxinjing shengxinjing changed the title support static tbody tr td elements support static tbody tr td elements Jun 4, 2020
@shengxinjing shengxinjing changed the title support static tbody tr td elements 1support static tbody tr td elements Jun 4, 2020
@shengxinjing shengxinjing changed the title 1support static tbody tr td elements support static tbody tr td elements Jun 4, 2020
@yyx990803 yyx990803 closed this in a938b61 Jun 9, 2020
@yyx990803
Copy link
Member

Thanks, skipping stringification at the compiler level is safer and more efficient. It also avoids adding more runtime code.

@shengxinjing
Copy link
Contributor Author

thanks for reply

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

Successfully merging this pull request may close these issues.

3 participants