Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
fix: #1717 #1727
fix: #1717 #1727
Conversation
I saw the issue was raised and a SheetJS Dev said the fix was simple and involved dealing with defined and undefined variables. They wrote a line using a ternary conditional to assign the variable textp to the value of cell.v if it's defined, or an empty string if it is not defined. SheetJS Dev Code: textp = cell.v == null ? "" : cell.v; Suggesting using the line: textp = cell.v || ""; This does the same thing and assigns textp to cell.v if it is defined or an empty string if it is not. (Note any feedback would be greatly appreciated, this is my first try at contributing to open source).
|
In JS there are 8 values that evaluate to false in a boolean context: |
|
Thank you for the great feedback and opportunity to dig into the code. I really appreciate your time. If so here is my idea, feel free to skip over this if I interpreted what you meant wrong. IDEA: Ultimately the code that passed all tests was: textp = (cell.v === undefined || cell.v === null || isNan(cell.v.toString)) ? "" : JSON.parse(cell.v); This code assigns the primitive value of the cell to the variable unless it is undefined, null or NaN. The function JSON.parse turns a string into JSON, and for this purpose, it essentially turns strings into primitives. END Thank you again for the feedback. I really enjoy learning more by solving problems. |
I saw the issue was raised and a SheetJS Dev said the fix was simple and involved dealing with defined and undefined variables.
They wrote a line using a ternary conditional to assign the variable textp to the value of cell.v if it's defined, or an empty string if it is not defined.
SheetJS Dev Code: textp = cell.v == null ? "" : cell.v;
Suggesting using the line: textp = cell.v || "";
This does the same thing and assigns textp to cell.v if it is defined or an empty string if it is not.
(Note any feedback would be greatly appreciated, this is my first try at contributing to open source).