-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Data: avoid using delete on DOM nodes #2479
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,13 +21,12 @@ Data.prototype = { | |
| if ( owner.nodeType ) { | ||
| owner[ this.expando ] = value; | ||
|
|
||
| // Otherwise secure it in a non-enumerable, non-writable property | ||
| // configurability must be true to allow the property to be | ||
| // deleted with the delete operator | ||
| // Otherwise secure it in a non-enumerable property | ||
| // configurable must be true to allow the property to be | ||
| // deleted when data is removed | ||
| } else { | ||
| Object.defineProperty( owner, this.expando, { | ||
| value: value, | ||
| writable: true, | ||
| configurable: true | ||
| }); | ||
| } | ||
|
|
@@ -147,7 +146,15 @@ Data.prototype = { | |
|
|
||
| // Remove the expando if there's no more data | ||
| if ( key === undefined || jQuery.isEmptyObject( cache ) ) { | ||
| delete owner[ this.expando ]; | ||
| // Support: Chrome <=35 - 45 | ||
| // Webkit & Blink performance suffers when deleting properties | ||
| // from DOM nodes, so set to undefined instead | ||
| // https://code.google.com/p/chromium/issues/detail?id=378607 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, i get 403 for this link, you don't?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get a 403 as well. It looks like google has made the bug private, maybe due to security issues with the bug?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm weird. @paulirish could you help us out? Can we add another link or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing can really be done here except remove the bug link. From the description of it given here, it either has a known security issue or they are verifying there isn't one before allowing it to be public again.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now this is a speculation, there might be a mistake or issues was moved, or basically anything else, i would like to wait day or two for the @paulirish response There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paul is on vacation. Surely won't respond within a few days.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I think we can add Duplicate that comment in Sounds good?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| if ( owner.nodeType ) { | ||
| owner[ this.expando ] = undefined; | ||
| } else { | ||
| delete owner[ this.expando ]; | ||
| } | ||
| } | ||
| }, | ||
| hasData: function( owner ) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,10 +283,14 @@ jQuery.extend({ | |
| } | ||
| } | ||
| } | ||
| delete elem[ dataPriv.expando ]; | ||
| // Support: Chrome <=35 - 45 | ||
| // Assign undefined instead of using delete, see Data#remove | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want the full comment copied here and below? Seemed like a lot to put in 3 places... |
||
| elem[ dataPriv.expando ] = undefined; | ||
| } | ||
| if ( elem[ dataUser.expando ] ) { | ||
| delete elem[ dataUser.expando ]; | ||
| // Support: Chrome <=35 - 45 | ||
| // Assign undefined instead of using delete, see Data#remove | ||
| elem[ dataUser.expando ] = undefined; | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be a "Support:" comment, we didn't do it for the
compatbut perhaps we should.So we talking about Safari, Chrome. Could you try to identify affected versions? I guess we can omit other Chromium browsers since we don't do it in other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI jquery/contribute.jquery.org#95 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess
Support: Chrome <=35 - 45then? It could have been an issue earlier but it looks like it was originally reported for Chrome35, and it seems to still be an issue last time I tested in 45.I'm not sure about Safari though. I don't recall ever seeing any webkit/safari bugs for this. I think the "Webkit &" was because it was noticeable in jsperf (#1664 (comment)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was is it noticeable specifically on Safari browser? If it was, can you recall version numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never tested safari myself so I'm not sure, I was just basing that on the comment: #1664 (comment)