-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Sprint3 #22018
Sprint3 #22018
Conversation
/** | ||
* GOALS: | ||
* - Patch types in tree shakable way | ||
* - Generate these types for files which have `matadatad.json` (since those are the files which |
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.
matadatad.json
? Typo?
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.
fixed
await r3.whenRendered(todoApp); | ||
expect(r3.getRenderedText(todoApp)).toEqual('...'); | ||
const firstCheckBox = | ||
r3.getHostElement(todoApp).querySelector('input[type]=checkbox') as HTMLElement; |
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.
Broken selector?
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.
fixed
* Use this function to bootstrap a component into the DOM tree. Each invocation | ||
* of this function will create a separate tree of components, injectors and | ||
* change detection cycles and lifetimes. To dynamically insert a new component into | ||
* existing tree such that it share the same injection, change detection and object |
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.
To dynamically insert a new component into an existing tree such that it shares the same injection
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.
fixed
* at some future point in time. This is because a single user action often results in many | ||
* components being invalidated and calling change detection on each component synchronously | ||
* would be inefficient. It is better to wait until all components re marked as dirty and | ||
* than perform single change detection across all of the components. |
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.
until all components are marked as dirty and then perform
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.
fixed
export function markDirty<T>(component: T) { | ||
const rootContext = getRootContext(component); | ||
let res: null|((val: null) => void); | ||
if (!(res = rootContext.cleanResolve)) { |
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.
res
shouldn't have to be assigned here, as its value is not used. In fact, res
is only used within the if.
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.
👍
* @param component Component for which the host element should be retrieved. | ||
*/ | ||
export function getHostElement<T>(component: T): HTMLElement { | ||
return ((component as any)[NG_HOST_SYMBOL] as LElementNode).native as any; |
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.
Similar to getRootContext
, this may benefit from ngDevMode asserts to verify the elementNode is present.
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.
👍
* Retrieves the rendered text for a given component. | ||
* | ||
* This function retrieves the host element of a component and | ||
* than returns the `textContent` for that element. This implies |
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.
and then returns
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.
👍
packages/core/testing/src/render3.ts
Outdated
* adds HTML to the `body` element of the `document` and subsequently tears it down. | ||
* | ||
* This function is intended to be used with `async await` and `Promise`s. If the wrapped | ||
* function returns a promise (or is `async`) than the teardown is delayed until that `Promise` |
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.
a promise (or is async
) then the teardown
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.
👍
packages/core/testing/src/render3.ts
Outdated
* function returns a promise (or is `async`) than the teardown is delayed until that `Promise` | ||
* is resolved. | ||
* | ||
* On `node` this function detects if `document` is preset and if not it will create one by |
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.
detects if document
is present and if not
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.
👍
@@ -6,10 +6,10 @@ | |||
* found in the LICENSE file at https://angular.io/license |
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.
Consider breaking this file into separate specs following the current nested defines, e.g. elements_spec.ts
, component_and_directives_spec.ts
, etc.
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.
That is my plan, but I want to land this before I will break it up
Hi @mhevery! This PR has merge conflicts due to recent upstream merges. |
62c5469
to
2fcfa61
Compare
*/ | ||
export function markDirty<T>(component: T) { | ||
const rootContext = getRootContext(component); | ||
if (!rootContext.cleanResolve) { |
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.
Come to think of it, we only use rootContext.cleanResolve
as a marker to indicate if the context is marked dirty, the function itself is not called as such as it is captured by the scheduled action closure below. We might as well choose not to expose the resolve function in RootContext
but only have a dirty
flag.
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 point, refactored
Hi @mhevery! This PR has merge conflicts due to recent upstream merges. |
@@ -157,9 +171,15 @@ export const NULL_INJECTOR: Injector = { | |||
|
|||
|
|||
/** | |||
* Bootstraps a Component into an existing host element and returns an instance | |||
* Bootstraps a Component into an existing host element and return an instance |
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.
Intentional change? I think returns
is actually clearer
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.
reverted
/** | ||
* A function which is used to schedule change detection work in the future. | ||
* | ||
* When marking components as dirty it is necessary to schedule the work of |
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.
Missing comma?
When marking components as dirty, it is necessary
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.
👍
* of this function will create a separate tree of components, injectors and | ||
* change detection cycles and lifetimes. To dynamically insert a new component | ||
* into an existing tree such that it shares the same injection, change detection | ||
* and object lifetime use {@link ViewContainer#createComponent}. |
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.
Missing comma?
object lifetime, use
...
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.
👍
isDirty = true; | ||
scheduler(() => detectChanges(component)); | ||
const lElementNode = (component as any)[NG_HOST_SYMBOL] as LElementNode; | ||
ngDevMode && assertNotNull(lElementNode, 'Not a component!'); |
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.
Replace lines 274-275 with _getComponentHostElementNode
?
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.
👍
* This function returns a `Promise` which is resolved when the component's | ||
* change detection is executed. This is determined by finding the scheduler | ||
* associated with the `component`'s render tree and waiting until the scheduler | ||
* flushes. If nothing is scheduled the function returns a resolved promise. |
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.
Missing comma? If nothing is scheduled, the function
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.
👍
cleanPromise: Promise<null>; | ||
|
||
/** | ||
* `clearPromise` resolution function when the change detection finishes. |
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.
Name outdated in this comment? Re names, what do you think about markAsClean
?
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.
removed per #22018 (comment)
* | ||
* This promise is overwritten every time a first call to {@link markDirty} is invoked. | ||
*/ | ||
cleanPromise: Promise<null>; |
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.
Nit: I read this the first time as "a promise that was clean" rather than "a promise that is resolved when components are clean". How about onClean
or componentsClean
?
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.
removed per #22018 (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.
LGTM
9e7252b
to
479f694
Compare
Sorry for an off-topic question, is there any plan to land the From the code seems that part has little coupling to ivy itself. |
Yes, that is our plan, but we want to make sure that it is working well with Ivy before we back port it into ViewEngine |
Hi @mhevery! This PR has merge conflicts due to recent upstream merges. |
ae11db5
to
fb929d3
Compare
b521f8b
to
ffe68af
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
markDirty
detectChanges
whenRendered
withBody
ensureDocument
cleanupDocument
update(separate CL)patch_types_spec.ts
with discussion per @chuckjazhell world bundle
tests to usewithBody
@IgorMinar & @chuckjaz Please check out
patch_types_spec.ts
if this is compatible with your understanding of the world.