Skip to content

Commit

Permalink
3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
imaustink committed Sep 29, 2017
1 parent 7ee6f37 commit a8ae53e
Show file tree
Hide file tree
Showing 2 changed files with 3,989 additions and 0 deletions.
99 changes: 99 additions & 0 deletions dist/amd/can-view-callbacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*can-view-callbacks@3.2.1#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) {
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) {
if (getGlobal().html5) {
getGlobal().html5.elements += ' ' + tagName;
getGlobal().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;
}()));
});
Loading

0 comments on commit a8ae53e

Please sign in to comment.