Skip to content

Conversation

@timmywil
Copy link
Member

@timmywil timmywil commented Sep 12, 2016

  • Renames and changes rnotwhite to focus on HTML whitespace chars
  • Change internal use of jQuery.trim to more accurate strip and collapse
  • Adds tests to ensure HTML space characters are retained where valid
  • Doesn't add tests where the difference is inconsequential and
    existing tests are adequate.

Fixes gh-3003
Fixes gh-3072

- Renames and changes rnotwhite to focus on HTML whitespace chars
- Change internal use of jQuery.trim to more accurate strip and collapse
- Adds tests to ensure HTML space characters are retained where valid
- Doesn't add tests where the difference is inconsequential and
  existing tests are adequate.

Fixes jquerygh-3003
Fixes jquerygh-3072
@mention-bot
Copy link

@timmywil, thanks for your PR! By analyzing the annotation information on this pull request, we identified @markelog, @mr21 and @mgol to be potential reviewers


// Strip and collapse whitespace according to HTML spec
// https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
var rhtmlSpace = /[\x20\t\r\n\f]+/g,
Copy link
Member

Choose a reason for hiding this comment

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

Can't you write a regular space ( ) instead of the hex code (\x20)?

Copy link
Member

@markelog markelog Sep 12, 2016

Choose a reason for hiding this comment

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

This is somehow should be different from [ \t\r\n\v\f] -> \s right? You guys already talked about this I believe?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is somehow should be different from [ \t\r\n\v\f] -> \s right?

Right

Copy link
Member

Choose a reason for hiding this comment

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

Could you give a me a context?

Copy link
Member Author

@timmywil timmywil Sep 12, 2016

Choose a reason for hiding this comment

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

Can't you write a regular space () instead of the hex code (\x20)?

We could, but I like that this is more apparent/explicit. It can be hard to notice a at first glance.

Copy link
Member

@mgol mgol Sep 12, 2016

Choose a reason for hiding this comment

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

@dmethvin No, / / doesn't match a tab.

EDIT: Ah, you mean it could be confused by a tab in the code, I see.

Copy link
Member

Choose a reason for hiding this comment

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

\x20 for most though, i think, that symbol doesn't immediately associated with

Copy link
Member

@dmethvin dmethvin Sep 12, 2016

Choose a reason for hiding this comment

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

Right, in the source it could be a tab. Unlikely, but the \x20 makes it super clear.

Copy link
Member

Choose a reason for hiding this comment

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

ooh, i see

Copy link
Member

Choose a reason for hiding this comment

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

Found the context, LGTM

@timmywil timmywil modified the milestone: 3.1.1 Sep 12, 2016
@timmywil timmywil closed this in 3bbcce6 Sep 15, 2016
@timmywil timmywil deleted the whitespace branch September 15, 2016 14:44
@gibson042 gibson042 mentioned this pull request Sep 16, 2016
4 tasks
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Class-related methods fail to meet w3c standard for whitespace handling Internal use of jQuery.trim erroneously strips too much

7 participants