Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
1b6be737
Commit
1b6be737
authored
Feb 27, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No ticket: Squeeze data
parent
8bc7bdeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
47 deletions
+35
-47
data.js
src/data.js
+35
-47
No files found.
src/data.js
View file @
1b6be737
...
@@ -51,13 +51,12 @@ Data.prototype = {
...
@@ -51,13 +51,12 @@ Data.prototype = {
return
unlock
;
return
unlock
;
},
},
set
:
function
(
owner
,
data
,
value
)
{
set
:
function
(
owner
,
data
,
value
)
{
var
prop
,
cache
,
unlock
;
var
prop
,
// There may be an unlock assigned to this node,
// There may be an unlock assigned to this node,
// if there is no entry for this "owner", create one inline
// if there is no entry for this "owner", create one inline
// and set the unlock as though an owner entry had always existed
// and set the unlock as though an owner entry had always existed
unlock
=
this
.
key
(
owner
),
unlock
=
this
.
key
(
owner
);
cache
=
this
.
cache
[
unlock
];
cache
=
this
.
cache
[
unlock
];
// Handle: [ owner, key, value ] args
// Handle: [ owner, key, value ] args
if
(
typeof
data
===
"string"
)
{
if
(
typeof
data
===
"string"
)
{
...
@@ -65,14 +64,13 @@ Data.prototype = {
...
@@ -65,14 +64,13 @@ Data.prototype = {
// Handle: [ owner, { properties } ] args
// Handle: [ owner, { properties } ] args
}
else
{
}
else
{
// [*] In the case where there was actually no "owner" entry and
// Support an expectation from the old data system where plain
// this.key( owner ) was called to create one, there will be
// objects used to initialize would be set to the cache by
// a corresponding empty plain object in the cache.
// reference, instead of having properties and values copied.
//
// Note, this will kill the connection between
// Note, this will kill the reference between
// "this.cache[ unlock ]" and "cache"
// "this.cache[ unlock ]" and "cache"
if
(
jQuery
.
isEmptyObject
(
cache
)
)
{
if
(
jQuery
.
isEmptyObject
(
cache
)
)
{
cache
=
data
;
this
.
cache
[
unlock
]
=
data
;
// Otherwise, copy the properties one-by-one to the cache object
// Otherwise, copy the properties one-by-one to the cache object
}
else
{
}
else
{
for
(
prop
in
data
)
{
for
(
prop
in
data
)
{
...
@@ -81,12 +79,6 @@ Data.prototype = {
...
@@ -81,12 +79,6 @@ Data.prototype = {
}
}
}
}
// [*] This is required to support an expectation made possible by the old
// data system where plain objects used to initialize would be
// set to the cache by reference, instead of having properties and
// values copied.
this
.
cache
[
unlock
]
=
cache
;
return
this
;
return
this
;
},
},
get
:
function
(
owner
,
key
)
{
get
:
function
(
owner
,
key
)
{
...
@@ -129,44 +121,40 @@ Data.prototype = {
...
@@ -129,44 +121,40 @@ Data.prototype = {
return
value
!==
undefined
?
value
:
key
;
return
value
!==
undefined
?
value
:
key
;
},
},
remove
:
function
(
owner
,
key
)
{
remove
:
function
(
owner
,
key
)
{
var
i
,
l
,
name
,
var
i
,
name
,
unlock
=
this
.
key
(
owner
),
unlock
=
this
.
key
(
owner
),
cache
=
this
.
cache
[
unlock
];
cache
=
this
.
cache
[
unlock
];
if
(
key
===
undefined
)
{
if
(
key
===
undefined
)
{
cache
=
{};
this
.
cache
[
unlock
]
=
{};
}
else
{
}
else
{
if
(
cache
)
{
// Support array or space separated string of keys
// Support array or space separated string of keys
if
(
jQuery
.
isArray
(
key
)
)
{
if
(
!
Array
.
isArray
(
key
)
)
{
// If "name" is an array of keys...
// Try the string as a key before any manipulation
// When data is initially created, via ("key", "val") signature,
if
(
key
in
cache
)
{
// keys will be converted to camelCase.
name
=
[
key
];
// Since there is no way to tell _how_ a key was added, remove
}
else
{
// both plain key and camelCase key. #12786
// If a key with the spaces exists, use it
.
// This will only penalize the array argument path
.
// Otherwise, create an array by matching non-whitespace
name
=
key
.
concat
(
key
.
map
(
jQuery
.
camelCase
)
);
name
=
jQuery
.
camelCase
(
key
);
}
else
{
name
=
name
in
cache
?
// Try the string as a key before any manipulation
[
name
]
:
(
name
.
match
(
core_rnotwhite
)
||
[]
);
if
(
key
in
cache
)
{
}
name
=
[
key
];
}
else
{
}
else
{
// If "name" is an array of keys...
// If a key with the spaces exists, use it.
// When data is initially created, via ("key", "val") signature,
// Otherwise, create an array by matching non-whitespace
// keys will be converted to camelCase.
name
=
jQuery
.
camelCase
(
key
);
// Since there is no way to tell _how_ a key was added, remove
name
=
name
in
cache
?
// both plain key and camelCase key. #12786
[
name
]
:
(
name
.
match
(
core_rnotwhite
)
||
[]
);
// This will only penalize the array argument path.
name
=
key
.
concat
(
key
.
map
(
jQuery
.
camelCase
)
);
}
}
i
=
0
;
}
l
=
name
.
length
;
for
(
;
i
<
l
;
i
++
)
{
i
=
name
.
length
;
delete
cache
[
name
[
i
]
];
while
(
i
--
)
{
}
delete
cache
[
name
[
i
]
];
}
}
}
}
this
.
cache
[
unlock
]
=
cache
;
},
},
hasData
:
function
(
owner
)
{
hasData
:
function
(
owner
)
{
return
!
jQuery
.
isEmptyObject
(
return
!
jQuery
.
isEmptyObject
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment