Skip to content

Commit

Permalink
List: update byId to work with elements not in the document
Browse files Browse the repository at this point in the history
Fixes #1318
  • Loading branch information
msssk committed Jun 19, 2020
1 parent 291bfae commit 181509c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions List.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
define(["dojo/_base/kernel", "dojo/_base/declare", "dojo/dom", "dojo/on", "dojo/has", "./util/misc", "dojo/has!touch?./TouchScroll", "xstyle/has-class", "put-selector/put", "dojo/_base/sniff", "xstyle/css!./css/dgrid.css"],
function(kernel, declare, dom, listen, has, miscUtil, TouchScroll, hasClass, put){
define(["dojo/_base/kernel", "dojo/_base/declare", "dojo/dom", "dojo/on", "dojo/query", "dojo/has", "./util/misc", "dojo/has!touch?./TouchScroll", "xstyle/has-class", "put-selector/put", "dojo/_base/sniff", "xstyle/css!./css/dgrid.css"],
function(kernel, declare, dom, listen, query, has, miscUtil, TouchScroll, hasClass, put){
// Add user agent/feature CSS classes
hasClass("mozilla", "opera", "webkit", "ie", "ie-6", "ie-6-7", "quirks", "no-quirks", "touch");

var oddClass = "dgrid-row-odd",
evenClass = "dgrid-row-even",
scrollbarWidth, scrollbarHeight;

function byId(id){
return document.getElementById(id);
function byId(id, context){
// document.getElementById only works for elements in the document
// dojo/query with the context parameter works for descendants of 'context' even when it is not in the document
return query('#' + miscUtil.escapeCssIdentifier(id), context)[0];
}

function cleanupTestElement(element){
Expand Down Expand Up @@ -411,7 +413,7 @@ function(kernel, declare, dom, listen, has, miscUtil, TouchScroll, hasClass, put
i;
for(i in this._rowIdToObject){
if(this._rowIdToObject[i] != this.columns){
var rowElement = byId(i);
var rowElement = byId(i, this.domNode);
if(rowElement){
this.removeRow(rowElement, true);
}
Expand Down Expand Up @@ -740,7 +742,7 @@ function(kernel, declare, dom, listen, has, miscUtil, TouchScroll, hasClass, put
id = this.id + "-row-" + (parentId ? parentId + "-" : "") +
((this.store && this.store.getIdentity) ?
this.store.getIdentity(object) : this._autoId++),
row = byId(id),
row = byId(id, this.domNode),
previousRow = row && row.previousSibling;

if(row){// if it existed elsewhere in the DOM, we will remove it, so we can recreate it
Expand Down Expand Up @@ -817,7 +819,7 @@ function(kernel, declare, dom, listen, has, miscUtil, TouchScroll, hasClass, put
id = target;
target = this._rowIdToObject[this.id + "-row-" + id];
}
return new this._Row(id, target, byId(this.id + "-row-" + id));
return new this._Row(id, target, byId(this.id + "-row-" + id, this.domNode));
},
cell: function(target){
// this doesn't do much in a plain list
Expand Down

0 comments on commit 181509c

Please sign in to comment.