-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Application wrapper div #280
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1afce81
Remove Application wrapper div
cibernox 917cf9a
Fix typo
cibernox 9b395e4
Fixing small grammatical glitches
acorncom 3f4f762
Merge pull request #12 from acorncom/patch-2
cibernox 56b08d5
Despicable => Minor
cibernox 2e3a980
Update 0000-remove-application-wrapper.md
locks 03e7195
Fix link
chancancode 86c77a4
Add ember PR link
chancancode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
- Start Date: 2017-12-11 | ||
- RFC PR: https://github.com/emberjs/rfcs/pull/280 | ||
- Ember Issue: (leave this empty) | ||
|
||
# Summary | ||
|
||
Introduce a low-level "flag" to remove the automatic wrapper `<div>` around | ||
Ember apps and tests. | ||
|
||
# Motivation | ||
|
||
In Ember applications today, applications are anchored to some existing HTML | ||
element in the page. Usually, this element is the `<body>` of the document, but it | ||
can be configured to be a different one when the application is defined, | ||
passing a CSS selector to the `rootElement` property: | ||
|
||
```js | ||
export default Ember.Application.extend({ | ||
rootElement: '#app' | ||
}); | ||
``` | ||
|
||
However, whatever the root is, the application adds another `<div>` wrapper | ||
that is not required anymore. It's a vestigial remainder of some implementation | ||
detail of how views worked in Ember 1.x. Some sort of wisdom tooth of the original | ||
rendering system that serves no purpose today. | ||
|
||
Furthermore, much like a wisdom tooth, it can give us problems. In the past, this element | ||
was configurable using the `ApplicationView`, but when views were removed we lost that | ||
ability. Right now we are stuck with a wrapper element we can't remove nor customize, | ||
which is why some apps target the selector `body > .ember-view` to style this element. | ||
|
||
Similarly, in testing there is another `.ember-view` wrapper inside the | ||
`#ember-testing` container for no good reason. | ||
|
||
This RFC proposes to add a global flag to remove those wrapper elements, | ||
effectively making the `application.hbs` template have "Outer HTML" semantics, which aligns | ||
well with [the changes recently proposed](#278) for template-only components, | ||
as well as the way Glimmer apps work. | ||
|
||
The same flag will also remove the unnecessary extra wrapper inside the testing | ||
container. | ||
|
||
# Detailed design | ||
|
||
## API Surface | ||
|
||
The proposed approach is identical to the one proposed in #278, quoted below: | ||
|
||
> We should not expose the flag directly as a public API. Instead, we should | ||
abstract the flag with a "privileged addon" whose only purpose is to enable | ||
the flag. Applications will enable the flag by installing this addon. This | ||
will allow for more flexibility in changing the flag's implementation (the | ||
location, naming, value, or even the existence of it) in the future. From the | ||
user's perspective, it is the addon that provides this functionality. The | ||
flag is simply an internal implementation detail. | ||
|
||
> We have done this before in other cases (such as the legacy view addon during | ||
the 2.0 transition period), and it has generally worked well. | ||
|
||
> When landing this feature, it will be entirely opt-in for existing apps, but | ||
the Ember CLI application blueprint should be updated to include the addon by | ||
default. At a later time, we should provide another addon that _disables_ the | ||
flag explicitly (installing both addons would be an install-time error). At | ||
that time, we will issue a deprecation warning if the flag is *not set*, with | ||
a message that directs the user to install one of the two addons. | ||
|
||
## Migration Path | ||
|
||
Given that this change only affects one single point in your application, | ||
I do not believe we need any specific strategy. If the users want to bring | ||
back the wrapper because it breaks their styles or some other reason, | ||
they can just add it manually on the `application.hbs` template, with | ||
any class or id they want. | ||
|
||
# How We Teach This | ||
|
||
This addon will be opt-in, but at some point it will become part of | ||
the default blueprint. This change, rather than introducing a new concept, *removes* | ||
an old one. Users won't have to google what is the way to remove or customize | ||
the implicit application wrapper of the app (to sadly discover that is not | ||
even possible), but instead they will add a wrapper only if they want, | ||
and in the same way they would add a wrapper in any other point of their application, | ||
with regular Handlebars. | ||
|
||
# Drawbacks | ||
|
||
There is a possibility that removing the wrapper can break styles for some apps, | ||
but since adding the wrapper back is just editing the `application.hbs` template, | ||
that is probably a minor drawback. | ||
|
||
There is also a non-zero chance that some testing addon is relying on the `#ember-testing > .ember-view` | ||
HTML hierarchy for some reason, and those addons would have to be updated. | ||
|
||
# Alternatives | ||
|
||
Leave things as they are today. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link to #278 is broken here (lmk if it was left intentionally I'm gonna remove this comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed!