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

builtIn types should not warn about safe string #666

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cherifGsoul
Copy link
Member

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.

@@ -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 () {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry my bad!

@@ -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) {
Copy link
Contributor

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)?

Copy link
Member Author

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>"])
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok thanks

Copy link
Contributor

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.

@phillipskevin phillipskevin dismissed their stale review January 18, 2019 22:52

My comments were addressed.

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