Skip to content

Commit 263bfa4

Browse files
committed
Check if pad name can be used as element id (#133)
If pad name has any special symbols or does not start from letter, replace pad name with global identifier.
1 parent 3af87bd commit 263bfa4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/JSRootPainter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4376,8 +4376,11 @@
43764376
this.pad = pad;
43774377
this.iscan = iscan; // indicate if working with canvas
43784378
this.this_pad_name = "";
4379-
if (!this.iscan && (pad !== null) && ('fName' in pad))
4379+
if (!this.iscan && (pad !== null) && ('fName' in pad)) {
43804380
this.this_pad_name = pad.fName.replace(" ", "_"); // avoid empty symbol in pad name
4381+
var regexp = new RegExp("^[A-Za-z][A-Za-z0-9_]*$");
4382+
if (!regexp.test(this.this_pad_name)) this.this_pad_name = 'jsroot_pad_' + JSROOT.id_counter++;
4383+
}
43814384
this.painters = []; // complete list of all painters in the pad
43824385
this.has_canvas = true;
43834386
}

0 commit comments

Comments
 (0)