-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[FEATURE ember-string-ishtmlsafe] Added Ember.String.isHtmlSafe. #13666
Conversation
85f3822
to
e7dd499
Compare
I think I figured out how to reintroduce this deprecation and maintain the It would be awesome if someone could code review my later commit (01fdfa0ae9daafd08ce899a9d6a73935ceebe675) and let me know if that's brilliant or stupid. I'm having a hard time deciding which 😜 . |
|
||
SafeString.apply(this, arguments); | ||
}; | ||
EmberHandlebars.SafeString.prototype = Object.create(SafeString.prototype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also specify the constructor?
EmberHandlebars.SafeString.prototype = Object.create(SafeString.prototype);
EmberHandlebars.SafeString.prototype.constructor = EmberHandlebars.SafeString;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also make SafeString
a getter, so that just using Ember.Handlebars.SafeString
issues the deprecation (even if you didn't invoke. This would help catch foo instanceof Ember.Handlebars.SafeString
with a deprecation also...
Took @rwjblue's advice and converted to using an object getter as the mechanism for deprecation. This is a cleaner solution and covers the deprecation more broadly. i.e. even using |
Looks like this needs a rebase. I'd also like to see about moving the test out of |
@rwjblue you mean a squash or just a rebase onto master?
That sounds straightforward. I can give it a shot. Do you have any examples of that off hand? |
@rwjblue I converted the related
Is there someone I should ping for a review who is familiar with the new glimmer test stuff? I didn't squash these commits to make it easier to review the testing changes. Once I get the 👍 I'll happily squash them down. |
if (isEnabled('ember-string-ishtmlsafe')) { | ||
EmberStringUtils.isHtmlSafe = isHtmlSafe; | ||
if (ENV.EXTEND_PROTOTYPES.String) { | ||
String.prototype.isHtmlSafe = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see the RFC (https://github.com/emberjs/rfcs/blob/master/text/0139-isHtmlSafe.md) does not suggest adding this. I think we should avoid adding another thing that modifies String.prototype
. Can you remove this block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right. I don't know why I did that. Ooops. I'll fix it.
Changes look good! Can you also add a test for the deprecated scenario also? ['@test isHtmlSafe should detect SafeString']() {
let safeString;
expectDeprecation(() => {
safeString = new EmberHandlebars.SafeString('<b>test</b>');
}, 'Ember.Handlebars.SafeString is deprecated in favor of Ember.String.htmlSafe');
this.assert.ok(isHtmlSafe(safeString));
} I updated the description with a final countdown checklist... |
…rjs/rfcs#139). Reintroduced deprecation of `new Ember.Handlebars.SafeString()`.
@rwjblue Alright, it should be good to go for whenever. Thanks again for your help. |
Not a blocker for merging, but I'd like to get the deprecation guide updated to mention transition from |
Thanks for working on this @workmanw! I will add this feature to the agenda for the next core team meeting to see if we can enable in canary (which will eventually be 2.8). |
@rwjblue I'd be happy to get the deprecation guide updated. I'll make sure the polyfill is in working order with this PR and see about linking it also. |
Seems like this should be |
I went with |
The convention is to use all lowercase if at the beginning, or all uppercase otherwise. The point is not to always uppercase or always lowercase, but to avoid mixed usage. |
@tomdale Ah, fair enough. I guess I'm not sure how I should have known that. There is nothing in the style guide about case and no one mentioned it during the RFC process. If there is consensus I can submit a new PR to update the feature and the deprecation guide; as well as change the polyfill. EDIT: I mean it's not much work at all. Like 10 minutes tops. I don't mind doing it, just wanted to make sure changing it is 👍 since it's a change outside the RFC. |
Yes, we discussed this at the core team meeting today, and this is the only blocker to enabling the features. @workmanw - Would you mind submitting an updating PR? |
Alrighty.
Happy friday. 🍻 |
@workmanw That convention is not documented AFAIK, and even if you tried to divine it from reading the tea leaves, I believe there are some inconsistencies in the codebase that could lead people astray. I guess that means I should document it somewhere. 😉 |
@tomdale No worries. Just trying to make sure I do my own due diligence before submitting PRs. |
RFC: emberjs/rfcs#139
The feature is ready to go. I just need to figure out how to deprecate using:
var safeStr = new Ember.Handlebars.SafeString('<div>Hello</div>');
without breaking
safeStr instanceOf Ember.Handlebars.SafeString
. If anyone has thoughts on that I'd love to hear them.TODO:
new Em.Handlebars.SafeString()
withEmber.String.isHtmlSafe()
.String.prototype
modification.