diff --git a/src/DOM.js b/src/DOM.js index 044d370676..ab4b19fd43 100644 --- a/src/DOM.js +++ b/src/DOM.js @@ -369,6 +369,7 @@ const _makeChildrenProxy = el => { const result = []; result.item = i => { if (typeof i === 'number') { + result.update(); return result[i]; } else { return undefined; @@ -376,16 +377,23 @@ const _makeChildrenProxy = el => { }; result.update = () => { result.length = 0; - - for (let i = 0; i < el.childNodes.length; i++) { - const childNode = el.childNodes[i]; + for (const childNode of el.childNodes) { if (childNode instanceof HTMLElement) { result.push(childNode); } } }; - result.update(); - return result; + + return new Proxy(result, { + get: function(e, prop) { + if (typeof prop === 'number') { + return e.item(prop); + } else { + result.update(); + return e[prop]; + } + }, + }); }; const _cssText = style => {