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

Escape the optgroup labels during initialization step. #969

Closed

Conversation

zsombor
Copy link
Contributor

@zsombor zsombor commented Jan 7, 2013

@pfiller here is the fix for the master branch. Will have to create one other for the harvest_experimental branch, just in case someone will overwrite the fixes we have in the harvestapp repo.

@@ -15,7 +15,7 @@ class SelectParser
@parsed.push
array_index: group_position
group: true
label: group.label
label: AbstractChosen.escapeExpression(group.label)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Making SelectParser call AbstractChosen for the escaping looks weird to me. Why not defining the method in the SelectParser instead ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @stof. I think this makes sense in the SelectParser class. Mind moving it @zsombor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay so assume that you need to escape from somewhere else as well. We certainly do escaping in the prototype & jQuery specific classes. Now will that helper function be named SelectParser.escapeExpression or AbstractChosen.escapeExpression, I don't like neither but would find the second one to be better. Perhaps Chosen.escapeExpression would be the best.

Copy link
Collaborator

Choose a reason for hiding this comment

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

currently, Chosen extends AbstractChosen and uses SelectParser. So IMO, SelectParser should nto depend on Chosen or AbstractChosen.

Thus, defining it directly in chosen is even worse than AbstractChosen as it would require duplicating it

Copy link
Contributor

Choose a reason for hiding this comment

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

Whether it winds up in SelectParser or AbstractChosen, I find it a little awkward. Between the two, I prefer it live in SelectParser. I wonder if we should consider introducing a third option instead - something like ChosenUtils. How does that sit with you @zsombor?

@pfiller
Copy link
Contributor

pfiller commented Jul 11, 2013

Holy crap this is old! Thanks @zsombor.

I've merged this commit into #1343 (Search Optgroups). Looks like that'll go out soon.

@pfiller pfiller closed this Jul 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants