Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

fix 109: trim spaces to fix one-time expression detection #122

Closed
wants to merge 1 commit into from
Closed

fix 109: trim spaces to fix one-time expression detection #122

wants to merge 1 commit into from

Conversation

OACDesigns
Copy link

this fixes #109 allowing for both {{ :: and {{:: which are valid syntax for one-time bindings.

The same is done in Angular 1.5.8 when detecting one-time binding in string expressions.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@OACDesigns
Copy link
Author

OACDesigns commented Dec 27, 2016

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@gkalpak
Copy link
Member

gkalpak commented Mar 24, 2017

@OACDesigns, thanks for fixing this. Could you also add a test for the fix in test/scopes.spec.js?

gkalpak added a commit to gkalpak/angular-hint that referenced this pull request Mar 30, 2017
Previously, one-time expressions were supposed to not trigger perf timers. There
were a couple of issues with the implementation:

1. One-time expressions were not detected as such if there was whitespace before
   the `::`.
2. It depended on internal AngularJS implementation details in a way that would
   fail to identify certain usecases (e.g. multiple interpolations in a single
   attribute value or node text).
3. Time spent on the initial evaluation of the one-time expressions would not be
   accounted for, but could still impact the duration of the first `$digest`.
4. While it is not common, there are cases were one-time expressions don't
   settle immediately. In such cases, their impact on the `$digest` should not
   be ignored.

This commit fixes the above issues by ensuring that only the "final" call to
`$watch` is intercepted (in contrast to intermediate calls that might call a
`$$watchDelegate`, which will then create the actual `$watch`er). One-time
expressions are intercepted normally and stop triggering perf times as soon as
their `unwatch` function is called.

Although the dependency on internal AngularJS implementation details could not
be avoided, the new implementation is a little more robust, as it relies on
fewer and less brittle details :D

Fixes angular#109
Closes angular#122
@gkalpak gkalpak closed this in 241aecb Mar 30, 2017
gkalpak added a commit that referenced this pull request Mar 30, 2017
Previously, one-time expressions were supposed to not trigger perf timers. There
were a couple of issues with the implementation:

1. One-time expressions were not detected as such if there was whitespace before
   the `::`.
2. It depended on internal AngularJS implementation details in a way that would
   fail to identify certain usecases (e.g. multiple interpolations in a single
   attribute value or node text).
3. Time spent on the initial evaluation of the one-time expressions would not be
   accounted for, but could still impact the duration of the first `$digest`.
4. While it is not common, there are cases were one-time expressions don't
   settle immediately. In such cases, their impact on the `$digest` should not
   be ignored.

This commit fixes the above issues by ensuring that only the "final" call to
`$watch` is intercepted (in contrast to intermediate calls that might call a
`$$watchDelegate`, which will then create the actual `$watch`er). One-time
expressions are intercepted normally and stop triggering perf times as soon as
their `unwatch` function is called.

Although the dependency on internal AngularJS implementation details could not
be avoided, the new implementation is a little more robust, as it relies on
fewer and less brittle details :D

Fixes #109
Closes #122

Closes #124
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$watch override makes one-time bindings in expressions to never clear the associated watch
3 participants