Giter VIP home page Giter VIP logo

Comments (4)

DimitarChristoff avatar DimitarChristoff commented on June 30, 2024 1

I guess. If you use Maps in your code, you're pretty confident you have a modern browser or good polyfills, you could use Object.assign() instead, merge loops only iterable properties and relies on clone for object like types or slice for arrays.

see https://github.com/mootools/mootools-core/blob/master/Source/Core/Core.js#L385-L412

as typeOf(new Map) returns an object... then we also see Object.clone(new Map(...)) returns an empty object.

the correct way to clone a Map is to return a new Map() but if it needs to be recursive... then the following needs to happen:

  • typeOf patched to detect instanceof Map / Set (hard as it does not polyfill and in older browsers these are not going to be defined)
  • patch Object.merge to different clone; or/ and...
  • fix Object.clone to recursively work with maps/sets

It's not a hard fix but if this is fixed, then a bunch of other parts would have to be made aware of new types and features. Not sure who'd have the time and energy to do all that...

from mootools-core.

DimitarChristoff avatar DimitarChristoff commented on June 30, 2024

don't use -compat version. https://jsfiddle.net/970Lzu45/12/

from mootools-core.

zortext avatar zortext commented on June 30, 2024

The example returns an empty object instead of Map.

https://jsfiddle.net/970Lzu45/30/

Tested with latest version of Chrome 69.0.3497.100

from mootools-core.

zortext avatar zortext commented on June 30, 2024

Ended up not modifying Mootools and using an extra method to merge this type of data.

Beware if you use Maps in Mootools Class options. SetOptions use Object.merge()

Deep merge supporting Maps:
https://gist.github.com/zortext/7e37142a91c9abfcc641f6e2dc306235
Maps will not be merged and will be keeped as they are.

from mootools-core.

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.