Giter VIP home page Giter VIP logo

Comments (10)

annevk avatar annevk commented on May 23, 2024

Whatever we do here should also be applied to URLSearchParams and Headers.

from xhr.

annevk avatar annevk commented on May 23, 2024

Having said that, most platform APIs today return null for not-present cases, e.g., getElementById() or getAttribute(). And types here are constrained whereas they are not with Map and Set.

from xhr.

domenic avatar domenic commented on May 23, 2024

Yeah, I agree with all that. I think it would be better to be consistent though since this is so clearly parallel to a Map. E.g. I can easily see myself or another developer writing code like const thingy = formData.get("key"); if (thingy !== undefined) { ... } based on their experiences with Maps.

from xhr.

travisleithead avatar travisleithead commented on May 23, 2024

Is there a reason why TC39 went with a return value of undefined? Any chance of getting them to change it?

from xhr.

domenic avatar domenic commented on May 23, 2024

undefined is definitely appropriate in ES semantics. It's what is always used in ES for missing values, e.g. try anyObject.aaidfjhosdfijdfjdof and you'll get undefined. No way that's changing.

from xhr.

annevk avatar annevk commented on May 23, 2024

This cannot really be fixed until whatwg/webidl#60 is fixed. And at that point I guess it depends largely on willingness of those implementing since this changes a bunch of APIs that have already been deployed.

from xhr.

annevk avatar annevk commented on May 23, 2024

@domenic is this still something you think we should pursue? Nobody has really moved the IDL issue along and I'm doubtful that implementers want to make a potentially breaking change here.

from xhr.

domenic avatar domenic commented on May 23, 2024

I still think it's worth fixing, without waiting for IDL (just use "any" like many other APIs that need to return undefined are doing). I don't know about implementer willingness to change though.

from xhr.

annevk avatar annevk commented on May 23, 2024

Fair, if anyone is interested in trying to make this happen, let me know. I'm not going to actively pursue this myself.

from xhr.

annevk avatar annevk commented on May 23, 2024

Given lack of interest and how risky this is, I'm closing this. Sorry.

from xhr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.