Opened 10 years ago

Last modified 10 years ago

#14978 closed enhancement

Dojo parser: parsing comma-separated elements into an array should support a way to escape commas inside elements — at Version 2

Reported by: Adrian Vasiliu Owned by: bill
Priority: undecided Milestone: tbd
Component: Parser Version: 1.7.2
Keywords: Cc: cjolif
Blocked By: Blocking:

Description (last modified by cjolif)

Various widgets have properties of type Array that can be specified in mark-up using strings. For example, one can specify

<div data-dojo-type=""

labels="'a','b'" ...>

or <div data-dojo-type=""

labels="a,b" ...>

The Dojo parser transforms these comma-separated strings into an array of 2 elements (this holds for both dojo/parser and dojox/mobile/parser).

So far so good, but it seems there's currently no easy way to include a comma in an element. Say, if we need an array of 2 elements, "a,A" and "b,B", specifying

<div data-dojo-type=""

labels="'a,A','b,B'" ...>

the parsed array contains 4, not 2 elements.

The following attempts to escape the comma character do not work either:

<div data-dojo-type=""

labels="'a\,A','b\,B'" ...>

<div data-dojo-type=""

labels="'a&#44;A','b&#44;B'" ...>

How to reproduce:

  1. Unzip the attached, say into the parent folder of dojo and dijit (otherwise, adapt the paths in test.html). This contains test.html which includes in mark-up three occurrences of a dijit widget defined in TestWidget?.js, using different ways to define an array of 2 elements each containing a comma.
  2. Run test/test.html

=> The console shows the elements of the parsed arrays. In all cases, the array has 4, not 2 elements.

Change History (3)

Changed 10 years ago by Adrian Vasiliu

Attachment: added

Sample for reproducing.

comment:1 Changed 10 years ago by cjolif

Cc: cjolif added
Component: GeneralParser
Owner: set to bill

comment:2 Changed 10 years ago by cjolif

Description: modified (diff)
Note: See TracTickets for help on using tickets.