diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2013-04-08 15:26:05 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2013-04-08 15:37:16 -0400 |
commit | d7d6b7a5c7992834fcd4d4b01eda87169704f032 (patch) | |
tree | 3481cdd0d600b3994590d43177464f2e80251343 /src | |
parent | 58a75a583bfe7ce49dc1a39f19d7ff0e3a4b7b67 (diff) | |
download | jquery-d7d6b7a5c7992834fcd4d4b01eda87169704f032.tar.gz jquery-d7d6b7a5c7992834fcd4d4b01eda87169704f032.zip |
Move Data.prototype.accept => Data.accepts
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/data.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/data.js b/src/data.js index 45d6ed052..ee4c7b3b7 100644 --- a/src/data.js +++ b/src/data.js @@ -15,7 +15,8 @@ var data_user, data_priv, function Data() { // Support: Android < 4, - // Old WebKit does not have Object.preventExtensions/freeze method, return new empty object instead + // Old WebKit does not have Object.preventExtensions/freeze method, + // return new empty object instead with no [[set]] accessor Object.defineProperty( this.cache = {}, 0, { get: function() { return {}; @@ -27,15 +28,26 @@ function Data() { Data.uid = 1; +Data.accepts = function( owner ) { + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + return owner.nodeType ? + owner.nodeType === 1 || owner.nodeType === 9 : true; +}; + Data.prototype = { key: function( owner ) { - // We can accept data for non-element nodes in modern browsers, but we should not, see #8335. - // Always return key for "freezed" object for such cases - if ( !this.accept( owner ) ) { + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return the key for a frozen object. + if ( !Data.accepts( owner ) ) { return 0; } - var descriptor = {}, // Check if the owner object already has a cache key unlock = owner[ this.expando ]; @@ -169,10 +181,6 @@ Data.prototype = { } } }, - accept: function( owner ) { - // Do not set data on non-element because it will not be cleared (#8335). - return owner.nodeType ? owner.nodeType === 1 || owner.nodeType === 9 : true; - }, hasData: function( owner ) { return !jQuery.isEmptyObject( this.cache[ owner[ this.expando ] ] || {} @@ -189,7 +197,7 @@ data_priv = new Data(); jQuery.extend({ - acceptData: data_user.accept, + acceptData: Data.accepts, hasData: function( elem ) { return data_user.hasData( elem ) || data_priv.hasData( elem ); |