Giter VIP home page Giter VIP logo

Comments (3)

jeffrose avatar jeffrose commented on August 30, 2024

+1

from json3.

 avatar commented on August 30, 2024

Hi @jaxley,

This was actually the default behavior before v3.2.3, but was changed after a lengthy discussion in #14. The problem with reverting to the pre-3.2.3 behavior is this: if RequireJS, curl, or another AMD loader is loaded in conjunction with a third-party script (say, Facebook Connect, which includes JSON 3), the polyfill won't be loaded unless it's specified as a dependency in a define call. As @jdalton explains:

This [the current behavior] is more for the uncontrolled use like when JSON3 is compiled into a widget that's included on a page that happens to also use AMD (so JSON3 used as a global and as an AMD module).

Libraries like jQuery and Lo-Dash mitigate this by exporting a global even if an AMD loader is present. Both libraries also provide a noConflict function, so the global can be removed if desired. Unfortunately, because JSON 3 is a polyfill that can extend the native JSON object, I'm wary of providing similar functionality—JSON.noConflict isn't a standard method. Another solution would be to expose a global JSON3 object, perhaps with an install or runInContext method. What do you think?

Edit: es-shims/es5-shim#167 is a compelling argument for why deferred execution with a module loader is undesirable.

from json3.

bnjmnt4n avatar bnjmnt4n commented on August 30, 2024

Closed via c05062. See #50.

from json3.

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.