3 ms·
I agree the API could be better, but note that you don't have to use IDs - you can also pass the parent element to display directly: https://github.com/zengm-ga
by yoavm 3y ago
I agree the API could be better, but note that you don't have to use IDs - you can also pass the parent element to display directly: https://github.com/zengm-games/facesjs/blob/master/src/display.ts#L254 https://github.com/zengm-games/facesjs/blob/master/src/displ...
- nox101 3y agoAs mentioned, that's still a poorer API than just returning a root element. Consider... // insert after every link document.querySelectorAll('a.funny').forEach(elem => const face = generate(); const parentForFace = document.createElement('span'); elem.appendChild(parentForFace); display(parentForFace); }); vs // insert after every link document.querySelectorAll('a.funny').forEach(elem => const face = generate(); elem.after(face.domElement); }); Taking a parent element is still a poor API