-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e5acde
commit 11701d7
Showing
2 changed files
with
4,075 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*can-view-callbacks@3.2.3#can-view-callbacks*/ | ||
define([ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-observation', | ||
'can-util/js/dev', | ||
'can-util/js/global', | ||
'can-util/dom/mutate', | ||
'can-namespace' | ||
], function (require, exports, module) { | ||
(function (global, require, exports, module) { | ||
var Observation = require('can-observation'); | ||
var dev = require('can-util/js/dev'); | ||
var getGlobal = require('can-util/js/global'); | ||
var domMutate = require('can-util/dom/mutate'); | ||
var namespace = require('can-namespace'); | ||
var attr = function (attributeName, attrHandler) { | ||
if (attrHandler) { | ||
if (typeof attributeName === 'string') { | ||
attributes[attributeName] = attrHandler; | ||
} else { | ||
regExpAttributes.push({ | ||
match: attributeName, | ||
handler: attrHandler | ||
}); | ||
} | ||
} else { | ||
var cb = attributes[attributeName]; | ||
if (!cb) { | ||
for (var i = 0, len = regExpAttributes.length; i < len; i++) { | ||
var attrMatcher = regExpAttributes[i]; | ||
if (attrMatcher.match.test(attributeName)) { | ||
return attrMatcher.handler; | ||
} | ||
} | ||
} | ||
return cb; | ||
} | ||
}; | ||
var attributes = {}, regExpAttributes = [], automaticCustomElementCharacters = /[-\:]/; | ||
var defaultCallback = function () { | ||
}; | ||
var tag = function (tagName, tagHandler) { | ||
if (tagHandler) { | ||
var GLOBAL = getGlobal(); | ||
if (GLOBAL.html5) { | ||
GLOBAL.html5.elements += ' ' + tagName; | ||
GLOBAL.html5.shivDocument(); | ||
} | ||
tags[tagName.toLowerCase()] = tagHandler; | ||
} else { | ||
var cb; | ||
if (tagHandler === null) { | ||
delete tags[tagName.toLowerCase()]; | ||
} else { | ||
cb = tags[tagName.toLowerCase()]; | ||
} | ||
if (!cb && automaticCustomElementCharacters.test(tagName)) { | ||
cb = defaultCallback; | ||
} | ||
return cb; | ||
} | ||
}; | ||
var tags = {}; | ||
var callbacks = { | ||
_tags: tags, | ||
_attributes: attributes, | ||
_regExpAttributes: regExpAttributes, | ||
defaultCallback: defaultCallback, | ||
tag: tag, | ||
attr: attr, | ||
tagHandler: function (el, tagName, tagData) { | ||
var helperTagCallback = tagData.options.get('tags.' + tagName, { proxyMethods: false }), tagCallback = helperTagCallback || tags[tagName]; | ||
var scope = tagData.scope, res; | ||
if (tagCallback) { | ||
res = Observation.ignore(tagCallback)(el, tagData); | ||
} else { | ||
res = scope; | ||
} | ||
if (res && tagData.subtemplate) { | ||
if (scope !== res) { | ||
scope = scope.add(res); | ||
} | ||
var result = tagData.subtemplate(scope, tagData.options); | ||
var frag = typeof result === 'string' ? can.view.frag(result) : result; | ||
domMutate.appendChild.call(el, frag); | ||
} | ||
} | ||
}; | ||
namespace.view = namespace.view || {}; | ||
if (namespace.view.callbacks) { | ||
throw new Error('You can\'t have two versions of can-view-callbacks, check your dependencies'); | ||
} else { | ||
module.exports = namespace.view.callbacks = callbacks; | ||
} | ||
}(function () { | ||
return this; | ||
}(), require, exports, module)); | ||
}); |
Oops, something went wrong.