Commit c1a2be03 authored by tsepez's avatar tsepez Committed by Commit bot

Mojo javascript encoder: Empty string encoded as NULL.

Instead, encode null as NULL (and not just any falsy value) via
a == comparison with null (and use ==, not === to treat undefined
the same way as null).

BUG=407258

Review URL: https://codereview.chromium.org/511443002

Cr-Commit-Position: refs/heads/master@{#292221}
parent b1828abc
...@@ -316,7 +316,8 @@ define("mojo/public/js/bindings/codec", [ ...@@ -316,7 +316,8 @@ define("mojo/public/js/bindings/codec", [
}; };
Encoder.prototype.encodeStructPointer = function(cls, val) { Encoder.prototype.encodeStructPointer = function(cls, val) {
if (!val) { if (val == null) {
// Also handles undefined, since undefined == null.
this.encodePointer(val); this.encodePointer(val);
return; return;
} }
...@@ -325,7 +326,8 @@ define("mojo/public/js/bindings/codec", [ ...@@ -325,7 +326,8 @@ define("mojo/public/js/bindings/codec", [
}; };
Encoder.prototype.encodeArrayPointer = function(cls, val) { Encoder.prototype.encodeArrayPointer = function(cls, val) {
if (!val) { if (val == null) {
// Also handles undefined, since undefined == null.
this.encodePointer(val); this.encodePointer(val);
return; return;
} }
...@@ -337,7 +339,8 @@ define("mojo/public/js/bindings/codec", [ ...@@ -337,7 +339,8 @@ define("mojo/public/js/bindings/codec", [
}; };
Encoder.prototype.encodeStringPointer = function(val) { Encoder.prototype.encodeStringPointer = function(val) {
if (!val) { if (val == null) {
// Also handles undefined, since undefined == null.
this.encodePointer(val); this.encodePointer(val);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment