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

simple bug: Inconsistencies around null and undefined #75

Open
amaramth opened this issue May 20, 2016 · 4 comments
Open

simple bug: Inconsistencies around null and undefined #75

amaramth opened this issue May 20, 2016 · 4 comments

Comments

@amaramth
Copy link

amaramth commented May 20, 2016

In code, plist.build({foo:undefined}) === plist.build({}) and plist.build({foo:null}) === plist.build(plist.parse(plist.build({foo:null}))) are not true and I think they should be.

exposition:

Javascript has null and undefined and [key missing]; JSON has null and [key missing]; plist has [key has no value] and [key missing]. I derive this from plist.build({foo:null}) !== plist.build({}), which is true and seems like it should be - this assumption might be false, though.

JSON.stringify,parse converts

  • javascript null ↔ json null
  • javascript [key missing] ↔ json [key missing]
  • javascript undefined → json [key missing]

plist.build,parse should do likewise, converting

  • javascript null ↔ plist [key has no value]
  • javascript [key missing] ↔ plist [key missing]
  • javascript undefined → plist [key missing].

Currently, it actually does

  • javascript null,undefined → plist [key has no value]
  • plist [key has no value] → javascript [key missing]
  • javascript [key missing] ↔ plist [key missing]

Can you reply with clarification? I don't know if that's the most consistent way to change this, or if it should be changed.

@amaramth amaramth changed the title inconsistencies around null and undefined Inconsistencies around null and undefined May 20, 2016
@amaramth amaramth changed the title Inconsistencies around null and undefined simple bug: Inconsistencies around null and undefined May 20, 2016
@TooTallNate
Copy link
Owner

👍 PR welcome

@mreinstein
Copy link
Collaborator

technically this would be an API change, so if you send a PR this would require bumping the major version on publish. Just putting this here as a reminder if/when that happens.

@lordgreg
Copy link

This i causing exactly the issue a-lot of Cordova users currently have:

Here is an example:

Cordova adds two keys with nullified values to plist, which plist reads them out:

  NSMainNibFile: null,
  'NSMainNibFile~ipad': null,

What plist (latest) is then doing is, it writes them back to plist (including all others possible options we write to config.xml). The objects above become:

    <key>NSMainNibFile</key>
    <value>NSMainNibFile~ipad</value>

Expected output:

--no output--

One option currently is to use the version 1.2.0 (yea, 1.2.0!) or, the hacky way to just remove both keys from plist "manually" from the string that plist module generates.

Both of them are totally wrong.

@mreinstein
Copy link
Collaborator

@amaramth I know this is a crazy-late reply, but I'm getting ready to start tackling a v4 of plist.js. If you're still interested in having this change go into a new major version, it's upcoming.

@mreinstein mreinstein mentioned this issue Aug 27, 2021
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

No branches or pull requests

4 participants