[BUGFIX beta] Trim whitespace in Ember.String.w()#14611
[BUGFIX beta] Trim whitespace in Ember.String.w()#14611treznick wants to merge 1 commit intoemberjs:masterfrom
Conversation
|
For anyone who notices this PR and is itching to work around it you can do the following: moduleFor("controller:foo/bar", "foo bar Controller", {
needs: Ember.String.w(`
controller:application
controller:foo
controller:bar/index
`.trim())
});Though I feel that intent behind |
|
Hello @treznick, in first place let me thank you for this PR. Also, we are really sorry to have let this PR stale and assure you we are working hard to minimise this kinds of situations in the future. Unfortunately, we are closing this in favor of discussing emberjs/rfcs#236 for deprecating the String extensions and quite likely extracting them to an addon. Thank you again for this PR! |
|
@Serabe no worries. In whatever shakes out of emberjs/rfcs#236 seems a much better place to have these conversations anyway. :) |
Currently,
Ember.String.w()has a bit of unexpected behavior when used in the context of theneedsproperty of amoduleForhelper. For instance, one might write the following code:and expect the result of
Ember.String.w()to be["controller:application", "controller:foo", "controller:bar/index"].Surprisingly, the result is
["", "controller:application", "controller:foo", "controller:bar/index", ""], which might be fine in and of itself, but blows the call stack ofmoduleFor:(This PR suggests that
Ember.String.w()trim whitespace before attempting to split on whitespace. It provides the end user a bit more flexibility with whitespacing of the argument string.I realize that much of the specific pain I encountered could be solved with better whitespacing in the first place, but it does seem a bit odd that
Ember.String.w()interprets leading and trailing whitespace as elements of the subsequent list to be respected.NB: I tagged this as a BUGFIX, but by all rights it could be a feature request. There's nothing broken per se about the behavior as is, but it does seem a bit surprising, especially when compared to other languages that support collection literals (e.g. ruby's percent strings). That said, I'm fairly novice to both the usage and architecture of ember, so if this isn't a behavior that would be desirable, feel free to disagree.