Is there a way to make this also work as a function? e.g. myTable.$$('tr').foreach()
import {qsA} from './dqs.js';
rows = qsA(myTable, 'tr');myTable.qsA('tr')
TypeError: myTable.qsA is not a function
HTMLElement.prototype.qsA = HTMLElement.prototype.querySelectorAll;
Now myTable.qsA('tr') will work. You can try it right here on the HN page in the browser console: HTMLElement.prototype.qsA = HTMLElement.prototype.querySelectorAll;
document.querySelector('#hnmain').qsA('tr');
Why do you prefer chaining?I suppose habit plus I find it easier to grok in that order, targetelement->childelements->foreach.