Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger the "changeId" event only if prevId is different from this.id. #4292

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

Noodlex
Copy link

@Noodlex Noodlex commented Sep 2, 2024

No description provided.

Copy link
Collaborator

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the effort to submit a fix, @Noodlex!

Could you please add a test that fails without your change, but passes with your change? Thanks in advance.

backbone.js Outdated
@@ -523,7 +523,9 @@
if (this.idAttribute in attrs) {
var prevId = this.id;
this.id = this.get(this.idAttribute);
this.trigger('changeId', this, prevId, options);
if(this.id !== prevId) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a space here for consistency's sake.

Suggested change
if(this.id !== prevId) {
if (this.id !== prevId) {

@jgonggrijp jgonggrijp linked an issue Sep 2, 2024 that may be closed by this pull request
@jgonggrijp
Copy link
Collaborator

Thanks again!

@jgonggrijp jgonggrijp merged commit 8f0285f into jashkenas:master Sep 2, 2024
1 check passed
@Noodlex Noodlex deleted the fix_model_event_changeId branch September 2, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trigger "changeId" need to be generate only if the content id change
2 participants