PDA

View Full Version : Ext.DomQuery's quickId does not work as expected for detached elements



jcdang
7 Dec 2013, 2:10 AM
function quickId(ns, mode, root, id) {
if (ns == root) {
id = unescapeCssSelector(id);
var d = root.ownerDocument || root;
return d.getElementById(id);
}
ns = getNodes(ns, mode, "*");
return byId(ns, id);
}

This doesn't work if root is detached from it's ownerDocument. The use case is when using a renderBuffer. The renderBuffer is detached and it's a clone of an existing attached element. If we do a query on the detached renderBuffer that doesn't work for querySelectorAll, quickId will use get the attached element.

I think this will fix it:


function quickId(ns, mode, root, id) {
if (ns == root) {
id = unescapeCssSelector(id);
var d = root.ownerDocument || root;
if (d.contains(root) && d.getElementById) {
return d.getElementById(id);
}
}
ns = getNodes(ns, mode, "*");
return byId(ns, id);
}

Gary Schlosberg
11 Dec 2013, 8:55 AM
Thanks for the report! Can you please post a test Fiddle (https://fiddle.sencha.com/#home) which reproduces the issue?