varvet / serenade.js

Client side MVC framework
http://serenadejs.org
Other
524 stars 27 forks source link

Uncaught TypeError: Cannot call method 'removeChild' of null #67

Closed JamesKyburz closed 12 years ago

JamesKyburz commented 12 years ago
    DynamicNode.prototype.remove = function() {
      this.clear();
      return this.anchor.parentNode.removeChild(this.anchor); // This line crashes because this.anchor.parentNode is undefined
    };

Adding the check

if (!this.anchor.parentNode) return this.anchor;

as the first line of the function works, but I am not sure what the root cause is yet....

How to replicate this issue


parent = """
div
  button[event:click=close] "Toggle"
  - if @show
    - in @details
      p "I am the ginger bread man catch me if you can " @name
"""

Serenade.view 'parent', parent

Controller = ->
  close: (model, element, event) -> model.set 'show', !!!model.get('show')

model = new Serenade.Model
  show: true
  details:
    name: 'haha'

Serenade.controller 'parent', Controller

document.body.appendChild Serenade.render 'parent', model
KirillGrishin commented 12 years ago

I wonder if this issue is same as the one that I talked about in google groups, there is a thread "How do I null properties of Serenade object in a correct way?" Jul 18th describing an alike problem.