cycle-snabbdom icon indicating copy to clipboard operation
cycle-snabbdom copied to clipboard

Root element is replaced

Open wclr opened this issue 9 years ago • 5 comments

It seems that root (container) element is being replaced while DOM update. I belive driver should leave it alone (as @cycle/dom does)

wclr avatar Mar 07 '16 11:03 wclr

I perform a check to avoid this here which is roughly the equivalent to what @cycle/dom does here

Do you spot an area where I'm doing an improper check?

TylorS avatar Mar 08 '16 19:03 TylorS

Well this code performs check if container changed

  import Cycle from '@cycle/core'
  import {h, div, makeDOMDriver} from 'cycle-snabbdom'
  import Rx from 'rx'
  var main = function(sources){
    return {
      DOM: Rx.Observable.just(1).map(x => div('x=' + x))
    }
  }

  var container = document.getElementById('app')
  setTimeout(() => {
    console.log('check', container == document.getElementById('app')) // check false
  })

  Cycle.run(main, {
    DOM: makeDOMDriver(container)
  })

It shows that container "has changed".

Hm, hm got the same result for cycle/dom in this test

wclr avatar Mar 08 '16 20:03 wclr

Just tried this http://esnextb.in/?gist=cc30f6b0513a4c2f74ee

TylorS avatar Mar 08 '16 20:03 TylorS

It's saying they are the same for me

TylorS avatar Mar 08 '16 20:03 TylorS

The problem is actuatual for sync version of cycle/core without setTimeout (for both dom drivers) https://github.com/cyclejs/core/issues/200 @staltz

wclr avatar Mar 08 '16 20:03 wclr