Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
579ea905
Commit
579ea905
authored
Dec 22, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CanJS: upgrade to 2.0.3
parent
f119005f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
69 deletions
+129
-69
architecture-examples/canjs/bower_components/canjs/can.jquery.js
...cture-examples/canjs/bower_components/canjs/can.jquery.js
+129
-69
No files found.
architecture-examples/canjs/bower_components/canjs/can.jquery.js
View file @
579ea905
/*!
* CanJS - 2.0.
2
* CanJS - 2.0.
3
* http://canjs.us/
* Copyright (c) 2013 Bitovi
* T
hu, 14 Nov 2013 18:45:17
GMT
* T
ue, 26 Nov 2013 18:21:35
GMT
* Licensed MIT
* Includes: can/component,can/construct,can/observe,can/compute,can/model,can/view,can/control,can/route,can/control/route,can/view/mustache,can/view/bindings,can/view/live,can/view/scope,can/util/string
* Includes: can/component,can/construct,can/
map,can/list,can/
observe,can/compute,can/model,can/view,can/control,can/route,can/control/route,can/view/mustache,can/view/bindings,can/view/live,can/view/scope,can/util/string
* Download from: http://canjs.com
*/
(
function
(
undefined
)
{
...
...
@@ -30,7 +30,7 @@
return
object
.
_cid
=
(
name
||
""
)
+
(
++
cid
)
}
}
can
.
VERSION
=
'
2.0.
2
'
;
can
.
VERSION
=
'
2.0.
3
'
;
can
.
simpleExtend
=
function
(
d
,
s
)
{
for
(
var
prop
in
s
)
{
...
...
@@ -384,24 +384,40 @@
oldClean
(
elems
);
};
var
oldDomManip
=
$
.
fn
.
domManip
;
var
oldDomManip
=
$
.
fn
.
domManip
,
cbIndex
;
$
.
fn
.
domManip
=
function
()
{
var
args
=
can
.
makeArray
(
arguments
),
isNew$
=
$
.
fn
.
jquery
>=
"
2.0.0
"
,
cbIndex
=
isNew$
?
1
:
2
,
callback
=
args
[
cbIndex
];
args
[
cbIndex
]
=
function
(
elem
)
{
var
isFragment
=
elem
.
nodeType
===
11
,
//Node.DOCUMENT_FRAGMENT_NODE,
targets
=
isFragment
?
can
.
makeArray
(
elem
.
childNodes
)
:
[
elem
],
ret
=
callback
.
apply
(
this
,
arguments
);
can
.
inserted
(
targets
);
return
ret
;
};
// feature detect which domManip we are using
$
.
fn
.
domManip
=
function
(
args
,
cb1
,
cb2
)
{
for
(
var
i
=
1
;
i
<
arguments
.
length
;
i
++
)
{
if
(
typeof
arguments
[
i
]
===
"
function
"
)
{
cbIndex
=
i
;
break
;
}
}
return
oldDomManip
.
apply
(
this
,
arguments
)
}
$
(
document
.
createElement
(
"
div
"
)).
append
(
document
.
createElement
(
"
div
"
))
return
oldDomManip
.
apply
(
this
,
args
);
};
$
.
fn
.
domManip
=
(
cbIndex
==
2
?
function
(
args
,
table
,
callback
)
{
return
oldDomManip
.
call
(
this
,
args
,
table
,
function
(
elem
)
{
if
(
elem
.
nodeType
===
11
)
{
var
elems
=
can
.
makeArray
(
elem
.
childNodes
);
}
var
ret
=
callback
.
apply
(
this
,
arguments
);
can
.
inserted
(
elems
?
elems
:
[
elem
]);
return
ret
;
})
}
:
function
(
args
,
callback
)
{
return
oldDomManip
.
call
(
this
,
args
,
function
(
elem
)
{
if
(
elem
.
nodeType
===
11
)
{
var
elems
=
can
.
makeArray
(
elem
.
childNodes
);
}
var
ret
=
callback
.
apply
(
this
,
arguments
);
can
.
inserted
(
elems
?
elems
:
[
elem
]);
return
ret
;
})
})
$
.
event
.
special
.
inserted
=
{};
$
.
event
.
special
.
removed
=
{};
...
...
@@ -1239,9 +1255,10 @@
madeMap
[
cid
]
=
{
obj
:
obj
,
instance
:
instance
,
added
:
hasCid
added
:
!
hasCid
}
}
return
teardown
;
};
teardownMap
=
function
()
{
for
(
var
cid
in
madeMap
)
{
...
...
@@ -1370,7 +1387,8 @@
// Sets all `attrs`.
this
.
_init
=
1
;
this
.
_setupComputes
();
var
teardownMapping
=
obj
&&
addToMap
(
obj
,
this
)
var
teardownMapping
=
obj
&&
addToMap
(
obj
,
this
);
var
data
=
can
.
extend
(
can
.
extend
(
true
,
{},
this
.
constructor
.
defaults
||
{}),
obj
)
this
.
attr
(
data
);
if
(
teardownMapping
)
{
...
...
@@ -1380,6 +1398,7 @@
delete
this
.
_init
;
},
_setupComputes
:
function
()
{
var
prototype
=
this
.
constructor
.
prototype
;
this
.
_computedBindings
=
{}
...
...
@@ -1707,6 +1726,12 @@
list
=
Map
(
{
Map
:
Map
},
{
setup
:
function
(
instances
,
options
)
{
this
.
length
=
0
;
...
...
@@ -1907,9 +1932,9 @@
can
.
extend
(
list
.
prototype
,
{
indexOf
:
function
(
item
)
{
indexOf
:
function
(
item
,
fromIndex
)
{
this
.
attr
(
'
length
'
)
return
can
.
inArray
(
item
,
this
)
return
can
.
inArray
(
item
,
this
,
fromIndex
)
},
...
...
@@ -2796,6 +2821,8 @@
// ## view/scope/scope.js
var
__m18
=
(
function
(
can
)
{
var
isObserve
=
function
(
obj
)
{
return
obj
instanceof
can
.
Map
||
(
obj
&&
obj
.
__get
);
},
...
...
@@ -2825,7 +2852,10 @@
var
Scope
=
can
.
Construct
.
extend
({
var
Scope
=
can
.
Construct
.
extend
(
{
// reads properties from a parent. A much more complex version of getObject.
read
:
function
(
parent
,
reads
,
options
)
{
...
...
@@ -2909,28 +2939,31 @@
parent
:
prev
};
}
},
{
init
:
function
(
data
,
parent
)
{
this
.
_data
=
data
;
},
{
init
:
function
(
context
,
parent
)
{
this
.
_context
=
context
;
this
.
_parent
=
parent
;
},
attr
:
function
(
attr
)
{
return
this
.
read
(
attr
,
{
attr
:
function
(
key
)
{
return
this
.
read
(
key
,
{
isArgument
:
true
,
returnObserveMethods
:
true
,
proxyMethods
:
false
}).
value
},
add
:
function
(
data
)
{
if
(
data
!==
this
.
_data
)
{
return
new
this
.
constructor
(
data
,
this
);
add
:
function
(
context
)
{
if
(
context
!==
this
.
_context
)
{
return
new
this
.
constructor
(
context
,
this
);
}
else
{
return
this
;
}
},
computeData
:
function
(
attr
,
options
)
{
computeData
:
function
(
key
,
options
)
{
options
=
options
||
{
args
:
[]
};
...
...
@@ -2952,7 +2985,7 @@
return
Scope
.
read
(
rootObserve
,
rootReads
,
options
).
value
}
// otherwise, go get the value
var
data
=
self
.
read
(
attr
,
options
);
var
data
=
self
.
read
(
key
,
options
);
rootObserve
=
data
.
rootObserve
;
rootReads
=
data
.
reads
;
computeData
.
scope
=
data
.
scope
;
...
...
@@ -2972,11 +3005,11 @@
return
this
.
_parent
.
read
(
attr
.
substr
(
3
),
options
)
}
else
if
(
attr
==
"
..
"
)
{
return
{
value
:
this
.
_parent
.
_
data
value
:
this
.
_parent
.
_
context
}
}
else
if
(
attr
==
"
.
"
||
attr
==
"
this
"
)
{
return
{
value
:
this
.
_
data
value
:
this
.
_
context
};
}
...
...
@@ -3023,7 +3056,7 @@
while
(
scope
)
{
// get the context
context
=
scope
.
_
data
;
context
=
scope
.
_
context
;
if
(
context
!=
null
)
{
...
...
@@ -3384,10 +3417,12 @@
// if this was an element like <foo-bar> that doesn't have a component, just render its content
var
res
=
tagCallback
?
tagCallback
(
el
,
hookupOptions
)
:
scope
,
scope
=
hookupOptions
.
scope
;
var
scope
=
hookupOptions
.
scope
,
res
=
tagCallback
?
tagCallback
(
el
,
hookupOptions
)
:
scope
;
if
(
res
)
{
// If the tagCallback gave us something to render with, and there is content within that element
// render it!
if
(
res
&&
hookupOptions
.
subtemplate
)
{
if
(
scope
!==
res
)
{
scope
=
scope
.
add
(
res
)
...
...
@@ -4016,12 +4051,12 @@
var
teardown
=
function
()
{
unbind
(
data
)
can
.
unbind
.
call
(
el
,
'
removed
'
,
teardown
);
return
true
},
data
=
{
// returns true if no parent
teardownCheck
:
function
(
parent
)
{
if
(
!
parent
)
{
teardown
();
}
return
parent
?
false
:
teardown
();
}
}
...
...
@@ -4071,6 +4106,12 @@
var
nodesMap
=
[],
// called when an item is added
add
=
function
(
ev
,
items
,
index
)
{
// check that the placeholder textNode still has a parent.
// it's possible someone removed the contents of
// this element without removing the parent
if
(
data
.
teardownCheck
(
text
.
parentNode
))
{
return
}
// Collect new html and mappings
var
frag
=
document
.
createDocumentFragment
(),
...
...
@@ -4098,7 +4139,17 @@
});
[].
splice
.
apply
(
nodesMap
,
[
index
,
0
].
concat
(
newMappings
));
},
remove
=
function
(
ev
,
items
,
index
)
{
// Remove can be called during teardown or when items are
// removed from the element.
remove
=
function
(
ev
,
items
,
index
,
duringTeardown
)
{
// If this is because an element was removed, we should
// check to make sure the live elements are still in the page.
// If we did this during a teardown, it would cause an infinite loop.
if
(
!
duringTeardown
&&
data
.
teardownCheck
(
text
.
parentNode
))
{
return
}
var
removedMappings
=
nodesMap
.
splice
(
index
,
items
.
length
),
itemsToRemove
=
[];
...
...
@@ -4124,7 +4175,7 @@
// use remove to clean stuff up for us
remove
({},
{
length
:
nodesMap
.
length
},
0
);
},
0
,
true
);
}
updateList
=
function
(
ev
,
newList
,
oldList
)
{
...
...
@@ -4140,11 +4191,7 @@
// Setup binding and teardown to add and remove events
var
data
=
setup
(
parentNode
,
function
()
{
if
(
text
.
parentNode
)
{
can
.
isFunction
(
compute
)
&&
compute
.
bind
(
"
change
"
,
updateList
)
}
else
{
data
.
teardownCheck
()
}
},
function
()
{
can
.
isFunction
(
compute
)
&&
compute
.
unbind
(
"
change
"
,
updateList
)
teardownList
()
...
...
@@ -4201,7 +4248,7 @@
var
parent
=
elements
.
getParentNode
(
el
,
parentNode
);
// setup listening right away so we don't have to re-calculate value
var
data
=
listen
(
el
.
parentNode
!==
parent
?
el
.
parentNode
:
parent
,
compute
,
function
(
ev
,
newVal
,
oldVal
)
{
var
data
=
listen
(
parent
,
compute
,
function
(
ev
,
newVal
,
oldVal
)
{
// Sometimes this is 'unknown' in IE and will throw an exception if it is
if
(
typeof
node
.
nodeValue
!=
'
unknown
'
)
{
node
.
nodeValue
=
""
+
newVal
;
...
...
@@ -4569,10 +4616,10 @@
// used to make sure .fn and .inverse are always called with a Scope like object
makeConvertToScopes
=
function
(
orignal
,
scope
,
options
)
{
return
function
(
updatedScope
,
updatedOptions
)
{
if
(
updatedScope
!=
null
&&
!
(
updatedScope
instanceof
can
.
view
.
Scope
))
{
if
(
updatedScope
!=
=
undefined
&&
!
(
updatedScope
instanceof
can
.
view
.
Scope
))
{
updatedScope
=
scope
.
add
(
updatedScope
)
}
if
(
updatedOptions
!=
null
&&
!
(
updatedOptions
instanceof
OptionsScope
))
{
if
(
updatedOptions
!=
=
undefined
&&
!
(
updatedOptions
instanceof
OptionsScope
))
{
updatedOptions
=
options
.
add
(
updatedOptions
)
}
return
orignal
(
updatedScope
,
updatedOptions
||
options
)
...
...
@@ -5153,7 +5200,7 @@
// Add the reference to the list in the contexts.
for
(
i
=
0
;
i
<
name
.
length
;
i
++
)
{
result
.
push
(
helperOptions
.
fn
(
name
[
i
]
||
''
));
result
.
push
(
helperOptions
.
fn
(
name
[
i
]));
// Ensure that live update works on observable lists
isObserveList
&&
name
.
attr
(
''
+
i
);
...
...
@@ -5174,7 +5221,7 @@
// This can cause issues if you are trying to
// eval on the length but this is the more
// common case.
return
''
+
(
name
!=
=
undefined
?
name
:
''
);
return
''
+
(
name
!=
undefined
?
name
:
''
);
break
;
}
}
...
...
@@ -5354,12 +5401,14 @@
if
(
expr
.
isComputed
||
isObserveLike
(
expr
)
&&
typeof
expr
.
attr
(
'
length
'
)
!==
'
undefined
'
)
{
return
can
.
view
.
lists
&&
can
.
view
.
lists
(
expr
,
function
(
item
,
key
)
{
// Create a compute that listens to whenever the index of the item in our list changes.
var
indexCompute
=
can
.
compute
(
function
()
{
var
exprResolved
=
Mustache
.
resolve
(
expr
);
return
(
exprResolved
).
indexOf
(
item
);
});
var
index
=
function
()
{
var
exprResolved
=
Mustache
.
resolve
(
expr
),
fromIndex
=
key
<
(
exprResolved
).
attr
(
'
length
'
)
?
key
:
undefined
;
return
(
exprResolved
).
indexOf
(
item
,
fromIndex
);
};
return
options
.
fn
(
options
.
scope
.
add
({
"
@index
"
:
index
Compute
"
@index
"
:
index
}).
add
(
item
));
});
}
...
...
@@ -5515,7 +5564,7 @@
returnObserveMethods
:
true
,
isArgument
:
true
});
return
scopeData
.
value
.
call
(
scopeData
.
parent
,
data
.
scope
.
_
data
,
can
.
$
(
this
),
ev
)
return
scopeData
.
value
.
call
(
scopeData
.
parent
,
data
.
scope
.
_
context
,
can
.
$
(
this
),
ev
)
};
if
(
special
[
event
])
{
...
...
@@ -5612,7 +5661,7 @@
var
self
=
this
;
this
.
on
(
this
.
scope
,
"
change
"
,
function
()
{
self
.
on
();
self
.
on
(
this
.
scope
,
"
change
"
,
arguments
.
callee
);
self
.
on
(
self
.
scope
,
"
change
"
,
arguments
.
callee
);
});
return
res
;
}
...
...
@@ -5627,10 +5676,18 @@
})
this
.
attributeScopeMappings
=
attributeScopeMappings
;
//
setup inheritance right away
//
If scope is an object,
if
(
!
this
.
prototype
.
scope
||
typeof
this
.
prototype
.
scope
===
"
object
"
)
{
// use that object as the prototype of an extened Map constructor function.
// A new instance of that Map constructor function will be created and
// set as this.scope.
this
.
Map
=
can
.
Map
.
extend
(
this
.
prototype
.
scope
||
{});
}
// If scope is a can.Map constructor function,
else
if
(
this
.
prototype
.
scope
.
prototype
instanceof
can
.
Map
)
{
// just use that.
this
.
Map
=
this
.
prototype
.
scope
;
}
...
...
@@ -5662,7 +5719,9 @@
component
=
this
,
twoWayBindings
=
{},
// what scope property is currently updating
scopePropertyUpdating
;
scopePropertyUpdating
,
// the object added to the scope
componentScope
;
// scope prototype properties marked with an "@" are added here
can
.
each
(
this
.
constructor
.
attributeScopeMappings
,
function
(
val
,
prop
)
{
...
...
@@ -5713,18 +5772,19 @@
})
var
componentScope
// save the scope
if
(
this
.
constructor
.
Map
)
{
componentScope
=
new
this
.
constructor
.
Map
(
initalScopeData
);
}
else
if
(
this
.
scope
instanceof
can
.
Map
)
{
componentScope
=
this
.
scope
;
}
else
if
(
can
.
isFunction
(
this
.
scope
))
{
var
scopeResult
=
this
.
scope
(
initalScopeData
,
hookupOptions
.
scope
,
el
);
// if the function returns a can.Map, use that as the scope
if
(
scopeResult
instanceof
can
.
Map
)
{
componentScope
=
scopeResult
}
else
if
(
typeof
scopeResult
==
"
function
"
&&
typeof
scopeResult
.
extend
==
"
function
"
)
{
}
else
if
(
scopeResult
.
prototype
instanceof
can
.
Map
)
{
componentScope
=
new
scopeResult
(
initalScopeData
);
}
else
{
componentScope
=
new
(
can
.
Map
.
extend
(
scopeResult
))(
initalScopeData
);
...
...
@@ -6099,6 +6159,7 @@
if
(
!
can
.
Model
)
{
return
;
}
this
.
List
=
ML
({
Map
:
this
},
{});
...
...
@@ -6267,7 +6328,6 @@
// Model lists are just like `Map.List` except that when their items are
// destroyed, it automatically gets removed from the list.
var
ML
=
can
.
Model
.
List
=
can
.
List
({
setup
:
function
(
params
)
{
if
(
can
.
isPlainObject
(
params
)
&&
!
can
.
isArray
(
params
))
{
...
...
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