Skip to content
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

Adds minor new API for enabling updating and querying assigned nodes. #860

Merged
merged 4 commits into from
Dec 9, 2019

Conversation

sorvell
Copy link
Member

@sorvell sorvell commented Dec 4, 2019

Adds a protected method called enableUpdating to UpdatingElement. Before this, updating is enabled when the element is connected in a way that is not easily customizable. Adding this API enables subclasses to control when updates are allowed to begin.

Adds a queryAssignedNodes(slotName: string, flatten: boolean) decorator. This provides a convenient way to retrieve the nodes distributed to a given slot via a property and is a shorthand for this.shadowRoot.querySelectorAll(slot[name=${slotName}]).assignedNodes(flatten).

Steven Orvell added 3 commits November 19, 2019 14:02
By default this is called in `connectedCallback`. Subclasses can customize when updating is initialized by overriding `connectedCallback` and calling `initializeUpdating`.
Copy link
Member

@kevinpschaaf kevinpschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Westbrook
Copy link
Contributor

Will this return the same nodes/be updated in the same way regardless of whether using the polyfill or not?

* A property decorator that converts a class property into a getter that
* returns the `assignedNodes` of the given named `slot`.
*
* @ExportDecoratedItems
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be @ExportDecoratedItems any more, as of angular/tsickle#1125

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

CHANGELOG.md Outdated
@@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- ### Added -->
<!-- ### Removed -->

### Added
* Added `enableUpdating()` to `UpdatingElement` to enable customizing when updating is enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SInce it doesn't look like we have issues for these, can you link to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/lib/decorators.ts Show resolved Hide resolved

/**
* A property decorator that converts a class property into a getter that
* returns the `assignedNodes` of the given named `slot`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should document the type that the property should be annotated with, ie NodeListOf<HTMLElement>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/test/lib/decorators_test.ts Show resolved Hide resolved
src/test/lib/decorators_test.ts Show resolved Hide resolved
src/lib/updating-element.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants