Skip to content

Commit

Permalink
stop using renderVirtual. causes React rendering problems with nested…
Browse files Browse the repository at this point in the history
… rendering
  • Loading branch information
arshaw committed Jul 29, 2020
1 parent 9becfdb commit f79728b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages-premium
3 changes: 1 addition & 2 deletions packages/common/src/main.ts
Expand Up @@ -69,8 +69,7 @@ export {
applyStyle,
applyStyleProp,
elementMatches,
elementClosest,
renderVirtual
elementClosest
} from './util/dom-manip'
export { parseClassNames } from './util/html'

Expand Down
10 changes: 0 additions & 10 deletions packages/common/src/util/dom-manip.ts
@@ -1,5 +1,4 @@
import { Dictionary } from '../options'
import { VNode, render } from '../vdom'


export function removeElement(el: HTMLElement) { // removes nodes in addition to elements. bad name
Expand All @@ -8,15 +7,6 @@ export function removeElement(el: HTMLElement) { // removes nodes in addition to
}
}

export function renderVirtual(v: VNode): HTMLElement { // TODO: use elsewhere?
let parentEl = document.createElement('div')
render(
v as any, // React only specifically accepts a vdom *element*, which we don't have a type for
parentEl
)
return parentEl.firstChild as HTMLElement
}


// Querying
// ----------------------------------------------------------------------------------------------------------------
Expand Down
22 changes: 7 additions & 15 deletions packages/common/src/util/table-styling.tsx
@@ -1,6 +1,3 @@
import { createElement } from '../vdom'
import { renderVirtual } from './dom-manip'


let canVGrowWithinCell: boolean

Expand All @@ -14,18 +11,13 @@ export function getCanVGrowWithinCell() {


function computeCanVGrowWithinCell() {
// TODO: abstraction for creating these temporary detection-based els
let el = renderVirtual(
<div style={{ position: 'absolute', top: 0, left: 0 }}>
<table style={{ height: 100 }}>
<tr>
<td>
<div style={{ height: '100%' }}></div>
</td>
</tr>
</table>
</div>
)
let el = document.createElement('div')
el.style.position = 'absolute'
el.style.top = '0px'
el.style.left = '0px'
el.innerHTML = '<div><table><tr><td><div></div></td></tr></table></div>'
el.querySelector('table').style.height = '100px'
el.querySelector('div').style.height = '100%'

document.body.appendChild(el)

Expand Down

0 comments on commit f79728b

Please sign in to comment.