[Bug]: different behavior when calling link.attr with object vs string
See original GitHub issueWhat 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:
- Created 9 months ago
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just checked the PR. This will be very useful without any doubt! Thank you for the fast patch! 🙏
Fixed in #1946 .