ractivejs / ractive

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

Accessing @shared property that include 'context' in their name throws a ParseError #3326

Closed giovannipiller closed 4 years ago

giovannipiller commented 4 years ago

Description:

Attempting to access a property within @shared that happens to include 'context' (lowercase) as part of its name, throws a ParseError.

ParseError: Expected closing delimiter '}}' after reference at line 1 character 11:
{{@shared.context}}
          ^----

This got noticed while attempting to access a shared property that was unfortunately called: {{@shared.globalDataset.contextBoxes}}.

Versions affected:

1.3.8

Platforms affected:

Tested on Chrome and Safari

Reproduction:

JSFiddle

const r = window.r = new Ractive({
  el: '#main',

  /**
   * Attempting to access any key in @shared that contains 'context' (lowercase) throws a ParseError.
   * For example, each of the following templates is invalid:
   */
  // template: `{{@shared.thisKeyContainscontext}}`,
  // template: `{{@shared.thecontextiskey}}`,
  // template: `{{@shared.anything.context}}`,
  template: `{{@shared.context}}`,
});
evs-chris commented 4 years ago

This should now be fixed on edge, 1.2, and 1.3. Thanks for the report!