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.

[Bug]: different behavior when calling link.attr with object vs string

See original GitHub issue

What happened?

I have my command manager subscribed to stack:push events. Playing around with .attr() I found out that it will trigger a stack:push events depending on what parameters I pass to it.

Example:

const link = new dia.standard.Link();
const cm = new dia.CommandManager(...);

cm.on("stack:push", (commands, opt) => {
  console.log(commands);
});

link.attr("line/stroke", "red");  // <-- this WON'T trigger stack:push


link.attr({                       // <-- this WILL trigger stack:push
  line: {  stroke: "red" },  
});

I tried debugging the internals of Joint / Backbone and it seems that, by the time Backbone’s .set() method is called, it’s _pending flag has a different value. This then causes line 540 (backbone.js) to be called.

I’m not really sure if I’m doing something I’m not supposed to or if this is a bug.

Also, this seems to be happening only with Links.

Version

3.6.2

What browsers are you seeing the problem on?

Chrome

What operating system are you seeing the problem on?

Mac

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alexandernstcommented, Dec 17, 2022

I just checked the PR. This will be very useful without any doubt! Thank you for the fast patch! 🙏

0reactions
kumilinguscommented, Dec 21, 2022

Fixed in #1946 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery .data() does not work, but .attr() does
I ran into a similar "bug" a few days ago when working with .data() and .attr('data-name') for HTML5 data attributes. The behavior you're...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Links in HTML documents
The default behavior associated with a link is the retrieval of another Web resource. This behavior is commonly and implicitly obtained by selecting...
Read more >
3. Data model — Python 3.11.1 documentation
All data in a Python program is represented by objects or by relations ... Some objects contain references to other objects; these are...
Read more >
The External Resource Link element - HTML - MDN Web Docs
The HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link ...
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