Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

docs(mdCompilerProvider): add respectPreAssignBindingsEnabled docs #11255

Merged
merged 1 commit into from
Apr 25, 2018

Conversation

Splaktar
Copy link
Contributor

PR Checklist

Please check that your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[ ] Infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

The docs site is missing the details about $mdCompilerProvider.respectPreAssignBindingsEnabled. The feature was added as part of #10016 and PR #10726. These docs can only be found in the code comments or CHANGELOG currently. It needs to be documented on the main docs site as well.

Issue Number:
Fixes #11252.

What is the new behavior?

$mdCompilerProvider.respectPreAssignBindingsEnabled is documented on the new $mdCompilerProvider docs page under Services.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

N/A

@Splaktar Splaktar added type: docs g3: reported The issue was reported by an internal or external product team. P3: important Important issues that really should be fixed when possible. labels Apr 24, 2018
@Splaktar Splaktar added this to the 1.1.9 milestone Apr 24, 2018
@Splaktar Splaktar requested a review from mgol April 24, 2018 22:13
@googlebot googlebot added the cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ label Apr 24, 2018
@Splaktar Splaktar added the needs: review This PR is waiting on review from the team label Apr 24, 2018
@Splaktar
Copy link
Contributor Author

@gkalpak can you please take a look at these docs changes to verify that they are still accurate with AngularJS 1.6 and the plans for AngularJS 1.7?

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

A couple of minor comments/typos.
LGTM otherwise 👍

* @returns {*} current value if used as getter or itself (chaining) if used as setter
* @param {boolean=} respected update the `respectPreAssignBindingsEnabled` state if provided, otherwise just return
* the current Material `respectPreAssignBindingsEnabled` state.
* @returns {boolean|function} current value if used as getter or itself (chaining) if used as setter
Copy link
Member

Choose a reason for hiding this comment

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

Why function? It returns the MdCompilerProvider instance if used as setter.

* @module material.core.compiler
* @description
* The $mdCompiler service is an abstraction of AngularJS's compiler, that allows developers
* to easily compile an element with options like in a Directive Definition Object.
* The `$mdCompiler` is able to respect the AngularJS `$compiler.preAssignBindingsEnabled` state when using
Copy link
Member

@gkalpak gkalpak Apr 24, 2018

Choose a reason for hiding this comment

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

$compiler.preAssignBindingsEnabled --> $compileProvider.preAssignBindingsEnabled (here and elsewhere).

* Only dynamic construction of elements such as Dialogs, Panels, Toasts, BottomSheets, etc. may be affected.
* Invoking `$mdCompilerProvider.respectPreAssignBindingsEnabled(true)` will make **bindings** in
* AngularJS Material custom components like `$mdDialog`, `$mdPanel`, `$mdToast`, or `$mdBottomSheet`
* only available in the controller constructors.
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is wrong. (As mentioned below, invoking $mdCompilerProvider.respectPreAssignBindingsEnabled(true) can result in different behaviors, depending on $compileProvider.preAssignBindingsEnabled() and AngularJS version.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I've cleaned this up.

* compileData.element; // Compiled DOM element
* compileData.link(myScope); // Instantiate controller and link element to scope.
* app.config(function($mdCompilerProvider) {
* $mdCompilerProvider.respectPreAssignBindingsEnabled(true);
Copy link
Member

Choose a reason for hiding this comment

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

Insufficient indentation 😇

* compileData.element // Content Element (same as above)
* compileData.link // This does nothing when using a contentElement.
* app.config(function($mdCompilerProvider) {
* $mdCompilerProvider.respectPreAssignBindingsEnabled(false);
Copy link
Member

Choose a reason for hiding this comment

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

Insufficient indentation. Also, this does not guarrantee that bindings are pre-assigned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that when $mdCompilerProvider.respectPreAssignBindingsEnabled(false) is called, it should guarantee that the bindings of AngularJS Material interim components are pre-assigned in AngularJS 1.5 and 1.6. Is this not correct? The description on line 119-120 seems pretty clear that the disabled (false) option doesn't depend on AngularJS versions or settings.

* compileData.link // This does nothing when using a contentElement.
* });
* function MyController() {
* // Locals from Angular Material are set yet. e.g myVar is true.
Copy link
Member

Choose a reason for hiding this comment

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

are set yet --> are set already (?)

@Splaktar Splaktar force-pushed the mdCompilerProviderDocs branch from 423a6db to cdd2918 Compare April 25, 2018 04:30
@Splaktar Splaktar added pr: merge ready This PR is ready for a caretaker to review pr: merge safe and removed needs: review This PR is waiting on review from the team labels Apr 25, 2018
* to easily compile an element with options like in a Directive Definition Object.
* The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using
* AngularJS versions between 1.5.10 and 1.7.0.
* See the [AngularJS documentation for `$compile.preAssignBindingsEnabled`
Copy link
Member

Choose a reason for hiding this comment

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

$compile --> $compileProvider

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh! Not sure how I missed those, thanks.

* > The compiler powers a lot of components inside of AngularJS Material.
* > Like the `$mdPanel` or `$mdDialog`.
* To enable/disable whether the controllers of dynamic AngularJS Material components
* (i.e. dialog, panel, toast, bottomsheet) respect the AngularJS `$compile.preAssignBindingsEnabled` flag,
Copy link
Member

Choose a reason for hiding this comment

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

$compile --> $compileProvider

* ](https://code.angularjs.org/1.6.4/docs/api/ng/provider/$compileProvider#preAssignBindingsEnabled)
* for more information.
* Call this method to enable/disable whether Material-specific (dialog/panel/toast/bottomsheet) controllers respect the
* AngularJS `$compile.preAssignBindingsEnabled` flag. Note that this doesn't affect directives/components created
Copy link
Member

Choose a reason for hiding this comment

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

$compile --> $compileProvider

* The $mdCompiler service is an abstraction of AngularJS's compiler, that allows developers
* to easily compile an element with options like in a Directive Definition Object.
* The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using
* AngularJS versions between 1.5.10 and 1.7.0.
Copy link
Member

Choose a reason for hiding this comment

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

It sounds like it respects it for 1.7.0 as well. How about:

 * The `$mdCompiler` is able to respect the AngularJS `$compileProvider.preAssignBindingsEnabled` state when using
 * AngularJS versions from 1.5.10 until (but not including) 1.7.0.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$compileProvider.preAssignBindingsEnabled is removed from AngularJS in 1.7.0. Maybe that's your point? I'll try to refine it.

* These constitute the majority of AngularJS Material and user-created components.
* Only dynamic construction of elements such as Dialogs, Panels, Toasts, BottomSheets, etc. may be affected.
* Invoking `$mdCompilerProvider.respectPreAssignBindingsEnabled(true)` will effect **bindings** in
* AngularJS Material custom components like `$mdDialog`, `$mdPanel`, `$mdToast`, or `$mdBottomSheet`.
Copy link
Member

Choose a reason for hiding this comment

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

$mdDialog etc. are services, not components. They don't even show components but usually templates with controllers (it'd be nice to add support for components but that's a separate story). Maybe:

...**bindings** in controllers created by AngularJS Material's services like $mdDialog, $mdPanel, $mdToast, or $mdBottomSheet.

?

* });
* </hljs>
*
* Example with a content element
* Assign Bindings Before the Constructor
Copy link
Member

Choose a reason for hiding this comment

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

This is only true for AngularJS <1.6.0 or AngularJS <1.7.0 if $compileProvider.preAssignBindingsEnabled(true) is called. Shouldn't it just say the reverse of the upper example's "Respect the AngularJS Compiler Setting"?

@Splaktar Splaktar removed the pr: merge ready This PR is ready for a caretaker to review label Apr 25, 2018
@andrewseguin andrewseguin merged commit 55ad25c into master Apr 25, 2018
@mgol
Copy link
Member

mgol commented Apr 25, 2018

@andrewseguin @Splaktar It seems none of my comments were addressed in the merged commit; do you plan followups?

Splaktar added a commit that referenced this pull request Apr 25, 2018
Splaktar added a commit that referenced this pull request Apr 25, 2018
@Splaktar
Copy link
Contributor Author

@mgol yep, sorry there was a miscommunication there. #11257 addresses the review feedback. Thank you very much for reviewing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ g3: reported The issue was reported by an internal or external product team. P3: important Important issues that really should be fixed when possible. type: docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs(mdCompilerProvider): missing from docs site
5 participants