-
Notifications
You must be signed in to change notification settings - Fork 12
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
builtIn types should not warn about safe string #666
base: master
Are you sure you want to change the base?
Conversation
test/stache-test.js
Outdated
@@ -6373,10 +6373,10 @@ function makeTest(name, doc, mutation) { | |||
|
|||
}); | |||
|
|||
testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", 3, function () { | |||
testHelpers.dev.devOnlyTest(" (#600)", 3, 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.
why did this testname change?
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 sorry my bad!
src/mustache_core.js
Outdated
@@ -381,7 +381,7 @@ var core = { | |||
else if(state.text && !valueShouldBeInsertedAsHTML(value)) { | |||
//!steal-remove-start | |||
if (process.env.NODE_ENV !== 'production') { | |||
if(value !== null && typeof value === "object") { | |||
if(value !== null && typeof value === "object" && canReflect.isBuiltIn(value) === false) { |
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 just use !canReflect.isBuiltIn(value)
?
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.
Done!
@@ -6376,7 +6376,7 @@ function makeTest(name, doc, mutation) { | |||
testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", 3, function () { | |||
|
|||
var map = new SimpleMap({ | |||
foo: ["<p></p>"] | |||
foo: new DefineList(["<p></p>"]) |
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.
It seems like #600 was specifically about Arrays, although I can't tell for sure, so I am not sure what is right here. I'm going to dismiss my review, but I think you should wait for @justinbmeyer to weigh in before merging.
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.
Ok thanks
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.
Yeah, I suppose Array and Objects are built-ins. Maybe the solution here is to do nothing until a Major release and then remove this warning. Or we should tell people to call obj.toString()
in the warning.
For #613
The expected behavior
When rendering a built in type (e.g: Date), stache shouldn't warn about using
stache.safeString
.The changes:
With the use of
canReflect.builtIn
I Check if the rendered object is built in one.