Component context isolation by default
**Although this doesn't bring much in terms of new functionality, there is a risk of it being a breaking change due to the change in default behaviour so thorough testing of this version in your project is highly recommended before deploying it to production.**
Explanation
Currently, variables defined in a parent view or component are implicitly made available to all child components whether you have passed them as attributes or not.
This can result in data unintentionally leaking across components sometimes leading to hard-to-trace side effects.
An example of the problem:
Imagine a variable `title` that has been made available to a component or view template called `parent.html`.
html
<!-- parent.html -->
{{ title }}
<c-child />
The child component also uses a variable named `title`:
html
<!-- child.html -->
{{ title }}
Before this release, parent's `title` is automatically made available to the child component. If it's intended that the child should have its own unique title, it becomes very easy to miss if we have forgotten to provide a title to child as it would use the title from parent context.
From now on `title` from the parent would not be available in the child - it should be passed explicitly as an attribute, like:
html
<!-- parent.html -->
<c-child title="{{ child_title }}" />
Summarising benefits of this approach:
- Missing variables will be more obvious to spot in development as context from other views and components cannot interfere.
- Defining attributes keeps data dependencies well defined making it clear to see what data components rely on, making jobs like refactoring and understanding easier.
Context processor context stays
Keeping a balance between component isolation whilst keeping some of the automatic benefits of Django Templates, data from any enabled context processor (builtin or custom) will remain available. (i.e. `{{ user }}`, `{{ request }}`, `{{ messages }}`, `{{ perms }}`)