question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor data.js to use a `Map`

See original GitHub issue

It seems dom/data.js is the perfect candidate for using a Map instead of the custom implementation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Johann-Scommented, Nov 20, 2020

yep it’s intended currently we don’t allow to use more than one plugin on a element

1reaction
alpadevcommented, Nov 17, 2020

@Johann-S sorry my stupid questions, but I try to fully understand the intention behind this code.

The current implementation, as far as I get it, doesn’t allow for multiple data on a single element at the same time, because setData will reuse the bsKey if it exists and override whatever data that is in storeData (without updating the key in that case). If you call setData on an element with different keys it will always override the information of the first used key, and getData will always return null for every other key aside the first one used. That’s the intended design?

Here is an example of an albeit fictional case that shows the implication of what I’m trying to say: https://codepen.io/-alpa-/pen/KKMExwM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplifying code with Maps in JavaScript | Alex Khomenko
Now that we're familiar with maps, let's refactor our component to take advantage of this data structure. const typeMap = new Map([ ["sessions" ......
Read more >
Refactoring every .forEach to a .map - DEV Community ‍ ‍
1. Use cases. map returns a new array without mutating the original, so it makes sense to use it if we are planning...
Read more >
Refactor React Code - Map Through API Data and ... - YouTube
Hi! I had a few people suggest that we break down the "Featured" component and pass through data to a component and then...
Read more >
How can I refactor my code to Javascript ES6 using map or ...
I would just generate a predicate from the second parameter. Since it contains a keys and a values, then Object.entries will de-compose it ......
Read more >
How to Use Map, Filter, and Reduce in JavaScript - Code
map is a method built to do exactly that. It's defined on Array.prototype , so you can call it on any array, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found