From 53002c64093d606243f6c94c6dbb8abd587e8dbf Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Fri, 20 Nov 2015 12:07:09 +0200 Subject: [PATCH] Fix bug wherein invalid ID can cause tree not to load --- jstreegrid.js | 17 +++++++++-------- package.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/jstreegrid.js b/jstreegrid.js index 8b2b890..ce284a0 100755 --- a/jstreegrid.js +++ b/jstreegrid.js @@ -29,7 +29,9 @@ } }(function ($) { var renderAWidth, renderATitle, getIndent, htmlstripre, findLastClosedNode, BLANKRE = /^\s*$/g, - IDREGEX = /[\\:&!^|()\[\]<>@*'+~#";,= \/${}%]/g, + IDREGEX = /[\\:&!^|()\[\]<>@*'+~#";,= \/${}%]/g, escapeId = function (id) { + return (id||"").replace(IDREGEX,'\\$&'); + }, SPECIAL_TITLE = "_DATA_", LEVELINDENT = 24, bound = false, styled = false, GRIDCELLID_PREFIX = "jsgrid_",GRIDCELLID_POSTFIX = "_col"; /*jslint regexp:true */ @@ -474,7 +476,7 @@ var dataRow = this.dataRow, children = node && node.children_d ? node.children_d : [], i; // go through each column, remove all children with the correct ID name for (i=0;i= peers.length-1 ? "NULL" : peers[pos+1]) +GRIDCELLID_POSTFIX+i; + gridCellNextId = GRIDCELLID_PREFIX+ escapeId(pos >= peers.length-1 ? "NULL" : peers[pos+1]) +GRIDCELLID_POSTFIX+i; gridCellNext = dataCell.find("div#"+gridCellNextId); - gridCellChildId = GRIDCELLID_PREFIX+ (objData.children && objData.children.length > 0 ? objData.children[0] : "NULL") +GRIDCELLID_POSTFIX+i; + gridCellChildId = GRIDCELLID_PREFIX+ escapeId(objData.children && objData.children.length > 0 ? objData.children[0] : "NULL") +GRIDCELLID_POSTFIX+i; gridCellChild = dataCell.find("div#"+gridCellChildId); gridCellParent = dataCell.find("div#"+gridCellParentId+i); diff --git a/package.json b/package.json index 3310c92..e8e0661 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jstreegrid", "description": "grid plugin for jstree", - "version": "3.3.0", + "version": "3.3.1", "url": "https://github.com/deitch/jstree-grid", "author": {"name":"Avi Deitcher","url":"https://github.com/deitch"}, "contributors": [