A longstanding problem with web app development is the lack of encapsulation when it comes to DOM element behavior and styles. We cannot segregate one part of the application HTML from another through any mechanism.
In fact, we have too much power at our disposal. With libraries such as jQuery and powerful CSS selectors, we can get hold of any DOM element and change its behavior. There is no distinction between our code and any external library code in terms of what it can access. Every single piece of code can manipulate any part of the rendered DOM. Hence, the encapsulation layer is broken. A badly written library can cause some nasty issues that are hard to debug.
The same holds true for CSS styling too. Any UI library implementation can override global styles if the library implementation wants to do so.
These are genuine challenges that any library developer faces when building reusable libraries. Some emerging web standards have tried to address...