Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

fix(parser) allow track by without filter #1477

Merged
merged 2 commits into from
Mar 6, 2016

Conversation

user378230
Copy link
Contributor

Allow track by without filter

Simple repeat expressions that used track by failed.

<ui-select-choices repeat="question in questions track by question.question_id"...>

The previous regex attempted to extract the filters from the expression but greedily included the track by portion too. The filters, however, are only needed when using an object as a source as ui-select needs to manually apply them when converting the object to an array.

Now the repeat parser will extract the source expression in one lump and let $parse deal with it if it can, only if an object source is used, will it attempt to extract the filters.

This more closely aligns ui-select with ngOption's parsing/regex (though it doesn't need to extract any filters).

Fixes #1233 #1462 #1263 #1270

Apologies if the regex is a bit messy - it is tested though!

user378230 added 2 commits March 5, 2016 23:04
Previously the parser always attempted to extract a filter from the repeat
expression, regardless of whether it was present or not. This resulted in
the track by part of the expression being interpreted as a filter.

This commit changes the parser regex to capture the entire object source,
including its filters, before matching any track by expression. The filters
are then extracted separately from the source as this step is only required
when using an object as a source.

Fixes angular-ui#1233
@user378230 user378230 changed the title Fix/parser Allow track by without filter Mar 6, 2016
@user378230 user378230 changed the title Allow track by without filter fix(parser) allow track by without filter Mar 6, 2016
aaronroberson added a commit that referenced this pull request Mar 6, 2016
fix(parser) allow track by without filter
@aaronroberson aaronroberson merged commit 9230b43 into angular-ui:master Mar 6, 2016
@aaronroberson
Copy link
Contributor

This has landed in [email protected]. Thanks @user378230!

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.

"track by" in simple comprehension expression broke when updating from 0.11.2 to 0.13.1
2 participants