ractivejs / ractive

Next-generation DOM manipulation
http://ractive.js.org
MIT License
5.94k stars 396 forks source link

Something very strange happened. Please file an issue at https://github.com/ractivejs/ractive/issues. Thanks! #965

Closed Madgvox closed 10 years ago

Madgvox commented 10 years ago

So this error just happened. Did some snooping and it looks like there's a types.CLOSING that gets passed into virtualdom_Fragment$init_createItem somehow. Here's the template that broke it (in jade):

| [[#buildConfig.categories]]

| {{#!!this.children}}
optgroup(value='[[this.id]]') [[this.text]]
    | [[#this.children]]
    option(value='[[this.id]]') [[this.text]]
    | [[/]]
| {{/}}

| {{#!this.children}}
options(value='[[this.id]]') [[this.text]]
| {{/}}

| [[/]]

(Please note: the weird combination of static and dynamic delimiters is due to wanting to build a static dropdown on init. Apparently static delimiters don't like/allow expressions though, so I was experimenting.

So as a side note, is there any way to do that?)

martypdx commented 10 years ago

@Madgvox I got it to work on the inner [[#this.children]] (http://codepen.io/martypdx/pen/rpuzJ):

    select
      {{#buildConfig.categories}}

      {{#!!this.children}}
      optgroup(label='[[this.text]]')
          [[#this.children]]
          option(value='[[this.id]]') [[this.text]]
          [[/]]

      {{else}}
      option(value='[[this.id]]') [[this.text]]
      {{/}}

      {{/}}

But if I change the outer [[#buildConfig.categories]], it parses that tag as text:

<select>[[#buildConfig.categories]] <option></option> [[/]]</select> 

Guess we should call it a bug. @jrajav any ideas?

(Here's the fork that doesn't work: http://codepen.io/martypdx/pen/BDmlI)

jonvuri commented 10 years ago

Maybe, I'll look into it tomorrow if I get time.

Rich-Harris commented 10 years ago

Turns out the parser wasn't identifying closing tags for static sections. Should be fixed now - reopen if there are still problems. Thanks