-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Debug Render Tree (for Ember Inspector) #18372
Conversation
b11090b
to
f62d281
Compare
7435de8
to
1ab8536
Compare
6f8b85c
to
33b0e6b
Compare
7c73f17
to
b422db1
Compare
This comment has been minimized.
This comment has been minimized.
@chancancode is it better to use |
1. Before loading Ember, set `ENV._DEBUG_RENDER_TREE = true;` This controls whether to perform extra bookkeeping needed to make the `captureRenderTree` API work. This has to be set before the ember JavaScript code is evaluated. This is usually done by setting one of these... ``` window.EmberENV = { _DEBUG_RENDER_TREE: true }; ``` ``` window.ENV = { _DEBUG_RENDER_TREE: true }; ``` ...before the "vendor" `<script>` tag in `index.html`. Setting the flag after Ember is already loaded will not work correctly. It may appear to work somewhat, but fundamentally broken. This is not intended to be set directly. Ember Inspector will enable the flag on behalf of the user as needed. This flag is always on in development mode. The flag is off by default in production mode, due to the cost associated with the the bookkeeping work. The expected flow is that Ember Inspector will ask the user to refresh the page after enabling the feature. It could also offer a feature where the user add some domains to the "always on" list. In either case, Ember Inspector will inject the code on the page to set the flag if needed. 2. With the flag on, `Ember._captureRenderTree()` is available. It takes the *application instance* as an argument and returns an array of `CapturedRenderNode`: ```typescript interface CapturedRenderNode { type: 'outlet' | 'engine' | 'route-template' | 'component'; name: string; args: { positional: unknown[]; named: Dict<unknown>; }; instance: unknown; bounds: Option<{ parentElement: Simple.Element; firstNode: Simple.Node; lastNode: Simple.Node; }>; children: CapturedRenderNode[]; } ``` Co-authored-by: Yehuda Katz <wycats@gmail.com>
b422db1
to
d7d942e
Compare
@rwwagner90 it is used like this: https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/environment/lib/env.ts#L206 Do you have a way to inject the script just before the vendor script tag? If so, you should probably try to detect if the app has already tried to set either of those and then go with it. If you have to inject at the very beginning of the page.. maybe you want to set |
We should only use window.EmberENV (usage of window.ENV is discouraged, and only exists as a form of legacy support). I’ll do a separate PR to add a deprecation if we find and use window.ENV. |
*/ | ||
export default function captureRenderTree(app: Owner): CapturedRenderNode[] { | ||
let env = expect( | ||
app.lookup<Environment>('service:-glimmer-environment'), |
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.
Do we have stripping for this in Ember's own packages?
Introduce debug render tree
Before loading Ember, set
ENV._DEBUG_RENDER_TREE = true;
This controls whether to perform extra bookkeeping needed to make the
captureRenderTree
API work.This has to be set before the ember JavaScript code is evaluated.
This is usually done by setting one of these...
...before the "vendor"
<script>
tag inindex.html
.Setting the flag after Ember is already loaded will not work correctly. It may appear to work somewhat, but fundamentally broken.
This is not intended to be set directly. Ember Inspector will enable the flag on behalf of the user as needed.
This flag is always on in development mode.
The flag is off by default in production mode, due to the cost associated with the the bookkeeping work.
The expected flow is that Ember Inspector will ask the user to refresh the page after enabling the feature. It could also offer a feature where the user add some domains to the "always on" list. In either case, Ember Inspector will inject the code on the page to set the flag if needed.
With the flag on,
Ember._captureRenderTree()
is available.It takes the application instance as an argument and returns an array of
CapturedRenderNode
: