mediamonks / muban

A backend-agnostic framework to enhance server-rendered HTML using a modern webpack development setup.
https://mediamonks.github.io/muban/
39 stars 15 forks source link

getElement's type states that it returns a HTMLElement, but it can also return null. #109

Closed skulptur closed 4 years ago

skulptur commented 4 years ago
const myElement = this.getElement('[data-non-existent]') // => null

I can see how it is convenient to assume that the element was found and move on with the code, but then when using that element it will inevitably fail and the error will not be immediately obvious. I suggest we at least use selectors that fail on the spot with a proper message, so we can easily find mistakes in the template.

ThaNarie commented 4 years ago

This is a duplicate of https://github.com/mediamonks/muban-core/issues/2, feel free to discuss there, since CoreComponent is part of muban-core :)