-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
3 changed files
with
342 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,76 @@ | ||
/*can-view-import@3.2.4#can-view-import*/ | ||
define([ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-assign', | ||
'can-dom-data-state', | ||
'can-globals/document', | ||
'can-util/dom/child-nodes', | ||
'can-util/js/import', | ||
'can-util/dom/mutate', | ||
'can-view-nodelist', | ||
'can-view-callbacks', | ||
'can-event', | ||
'can-log/', | ||
'can-log/dev' | ||
], function (require, exports, module) { | ||
(function (global, require, exports, module) { | ||
var assign = require('can-assign'); | ||
var canData = require('can-dom-data-state'); | ||
var DOCUMENT = require('can-globals/document'); | ||
var getChildNodes = require('can-util/dom/child-nodes'); | ||
var importer = require('can-util/js/import'); | ||
var mutate = require('can-util/dom/mutate'); | ||
var nodeLists = require('can-view-nodelist'); | ||
var viewCallbacks = require('can-view-callbacks'); | ||
var tag = viewCallbacks.tag; | ||
var events = require('can-event'); | ||
var canLog = require('can-log/'); | ||
var dev = require('can-log/dev'); | ||
function processImport(el, tagData) { | ||
var moduleName = el.getAttribute('from'); | ||
var templateModule = tagData.options.get('helpers.module'); | ||
var parentName = templateModule ? templateModule.id : undefined; | ||
if (!moduleName) { | ||
return Promise.reject('No module name provided'); | ||
} | ||
var importPromise = importer(moduleName, parentName); | ||
importPromise.catch(function (err) { | ||
canLog.error(err); | ||
}); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
var scope = tagData.scope.add(importPromise); | ||
var handOffTag = el.getAttribute('can-tag'); | ||
if (handOffTag) { | ||
var callback = tag(handOffTag); | ||
if (!callback || callback === viewCallbacks.defaultCallback) { | ||
} else { | ||
canData.set.call(el, 'preventDataBindings', true); | ||
callback(el, assign(tagData, { scope: scope })); | ||
canData.set.call(el, 'preventDataBindings', false); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
} | ||
} else { | ||
var frag = tagData.subtemplate ? tagData.subtemplate(scope, tagData.options) : DOCUMENT().createDocumentFragment(); | ||
var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); | ||
nodeList.expression = '<' + this.tagName + '>'; | ||
events.one.call(el, 'removed', function () { | ||
nodeLists.unregister(nodeList); | ||
}); | ||
mutate.appendChild.call(el, frag); | ||
nodeLists.update(nodeList, getChildNodes(el)); | ||
} | ||
} | ||
[ | ||
'can-import', | ||
'can-dynamic-import' | ||
].forEach(function (tagName) { | ||
tag(tagName, processImport.bind({ tagName: tagName })); | ||
}); | ||
}(function () { | ||
return this; | ||
}(), require, exports, module)); | ||
}); |
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,55 @@ | ||
/*can-view-import@3.2.4#can-view-import*/ | ||
var assign = require('can-assign'); | ||
var canData = require('can-dom-data-state'); | ||
var DOCUMENT = require('can-globals/document/document'); | ||
var getChildNodes = require('can-util/dom/child-nodes/child-nodes'); | ||
var importer = require('can-util/js/import/import'); | ||
var mutate = require('can-util/dom/mutate/mutate'); | ||
var nodeLists = require('can-view-nodelist'); | ||
var viewCallbacks = require('can-view-callbacks'); | ||
var tag = viewCallbacks.tag; | ||
var events = require('can-event'); | ||
var canLog = require('can-log/can-log'); | ||
var dev = require('can-log/dev/dev'); | ||
function processImport(el, tagData) { | ||
var moduleName = el.getAttribute('from'); | ||
var templateModule = tagData.options.get('helpers.module'); | ||
var parentName = templateModule ? templateModule.id : undefined; | ||
if (!moduleName) { | ||
return Promise.reject('No module name provided'); | ||
} | ||
var importPromise = importer(moduleName, parentName); | ||
importPromise.catch(function (err) { | ||
canLog.error(err); | ||
}); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
var scope = tagData.scope.add(importPromise); | ||
var handOffTag = el.getAttribute('can-tag'); | ||
if (handOffTag) { | ||
var callback = tag(handOffTag); | ||
if (!callback || callback === viewCallbacks.defaultCallback) { | ||
} else { | ||
canData.set.call(el, 'preventDataBindings', true); | ||
callback(el, assign(tagData, { scope: scope })); | ||
canData.set.call(el, 'preventDataBindings', false); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
} | ||
} else { | ||
var frag = tagData.subtemplate ? tagData.subtemplate(scope, tagData.options) : DOCUMENT().createDocumentFragment(); | ||
var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); | ||
nodeList.expression = '<' + this.tagName + '>'; | ||
events.one.call(el, 'removed', function () { | ||
nodeLists.unregister(nodeList); | ||
}); | ||
mutate.appendChild.call(el, frag); | ||
nodeLists.update(nodeList, getChildNodes(el)); | ||
} | ||
} | ||
[ | ||
'can-import', | ||
'can-dynamic-import' | ||
].forEach(function (tagName) { | ||
tag(tagName, processImport.bind({ tagName: tagName })); | ||
}); |
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,211 @@ | ||
/*[global-shim-start]*/ | ||
(function(exports, global, doEval) { | ||
// jshint ignore:line | ||
var origDefine = global.define; | ||
|
||
var get = function(name) { | ||
var parts = name.split("."), | ||
cur = global, | ||
i; | ||
for (i = 0; i < parts.length; i++) { | ||
if (!cur) { | ||
break; | ||
} | ||
cur = cur[parts[i]]; | ||
} | ||
return cur; | ||
}; | ||
var set = function(name, val) { | ||
var parts = name.split("."), | ||
cur = global, | ||
i, | ||
part, | ||
next; | ||
for (i = 0; i < parts.length - 1; i++) { | ||
part = parts[i]; | ||
next = cur[part]; | ||
if (!next) { | ||
next = cur[part] = {}; | ||
} | ||
cur = next; | ||
} | ||
part = parts[parts.length - 1]; | ||
cur[part] = val; | ||
}; | ||
var useDefault = function(mod) { | ||
if (!mod || !mod.__esModule) return false; | ||
var esProps = { __esModule: true, default: true }; | ||
for (var p in mod) { | ||
if (!esProps[p]) return false; | ||
} | ||
return true; | ||
}; | ||
|
||
var hasCjsDependencies = function(deps) { | ||
return ( | ||
deps[0] === "require" && deps[1] === "exports" && deps[2] === "module" | ||
); | ||
}; | ||
|
||
var modules = | ||
(global.define && global.define.modules) || | ||
(global._define && global._define.modules) || | ||
{}; | ||
var ourDefine = (global.define = function(moduleName, deps, callback) { | ||
var module; | ||
if (typeof deps === "function") { | ||
callback = deps; | ||
deps = []; | ||
} | ||
var args = [], | ||
i; | ||
for (i = 0; i < deps.length; i++) { | ||
args.push( | ||
exports[deps[i]] | ||
? get(exports[deps[i]]) | ||
: modules[deps[i]] || get(deps[i]) | ||
); | ||
} | ||
// CJS has no dependencies but 3 callback arguments | ||
if (hasCjsDependencies(deps) || (!deps.length && callback.length)) { | ||
module = { exports: {} }; | ||
args[0] = function(name) { | ||
return exports[name] ? get(exports[name]) : modules[name]; | ||
}; | ||
args[1] = module.exports; | ||
args[2] = module; | ||
} else if (!args[0] && deps[0] === "exports") { | ||
// Babel uses the exports and module object. | ||
module = { exports: {} }; | ||
args[0] = module.exports; | ||
if (deps[1] === "module") { | ||
args[1] = module; | ||
} | ||
} else if (!args[0] && deps[0] === "module") { | ||
args[0] = { id: moduleName }; | ||
} | ||
|
||
global.define = origDefine; | ||
var result = callback ? callback.apply(null, args) : undefined; | ||
global.define = ourDefine; | ||
|
||
// Favor CJS module.exports over the return value | ||
result = module && module.exports ? module.exports : result; | ||
modules[moduleName] = result; | ||
|
||
// Set global exports | ||
var globalExport = exports[moduleName]; | ||
if (globalExport && !get(globalExport)) { | ||
if (useDefault(result)) { | ||
result = result["default"]; | ||
} | ||
set(globalExport, result); | ||
} | ||
}); | ||
global.define.orig = origDefine; | ||
global.define.modules = modules; | ||
global.define.amd = true; | ||
ourDefine("@loader", [], function() { | ||
// shim for @@global-helpers | ||
var noop = function() {}; | ||
return { | ||
get: function() { | ||
return { prepareGlobal: noop, retrieveGlobal: noop }; | ||
}, | ||
global: global, | ||
__exec: function(__load) { | ||
doEval(__load.source, global); | ||
} | ||
}; | ||
}); | ||
})( | ||
{}, | ||
typeof self == "object" && self.Object == Object ? self : window, | ||
function(__$source__, __$global__) { | ||
// jshint ignore:line | ||
eval("(function() { " + __$source__ + " \n }).call(__$global__);"); | ||
} | ||
); | ||
|
||
/*can-view-import@3.2.4#can-view-import*/ | ||
define('can-view-import', [ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-assign', | ||
'can-dom-data-state', | ||
'can-globals/document/document', | ||
'can-util/dom/child-nodes/child-nodes', | ||
'can-util/js/import/import', | ||
'can-util/dom/mutate/mutate', | ||
'can-view-nodelist', | ||
'can-view-callbacks', | ||
'can-event', | ||
'can-log/can-log', | ||
'can-log/dev/dev' | ||
], function (require, exports, module) { | ||
(function (global, require, exports, module) { | ||
var assign = require('can-assign'); | ||
var canData = require('can-dom-data-state'); | ||
var DOCUMENT = require('can-globals/document/document'); | ||
var getChildNodes = require('can-util/dom/child-nodes/child-nodes'); | ||
var importer = require('can-util/js/import/import'); | ||
var mutate = require('can-util/dom/mutate/mutate'); | ||
var nodeLists = require('can-view-nodelist'); | ||
var viewCallbacks = require('can-view-callbacks'); | ||
var tag = viewCallbacks.tag; | ||
var events = require('can-event'); | ||
var canLog = require('can-log/can-log'); | ||
var dev = require('can-log/dev/dev'); | ||
function processImport(el, tagData) { | ||
var moduleName = el.getAttribute('from'); | ||
var templateModule = tagData.options.get('helpers.module'); | ||
var parentName = templateModule ? templateModule.id : undefined; | ||
if (!moduleName) { | ||
return Promise.reject('No module name provided'); | ||
} | ||
var importPromise = importer(moduleName, parentName); | ||
importPromise.catch(function (err) { | ||
canLog.error(err); | ||
}); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
var scope = tagData.scope.add(importPromise); | ||
var handOffTag = el.getAttribute('can-tag'); | ||
if (handOffTag) { | ||
var callback = tag(handOffTag); | ||
if (!callback || callback === viewCallbacks.defaultCallback) { | ||
} else { | ||
canData.set.call(el, 'preventDataBindings', true); | ||
callback(el, assign(tagData, { scope: scope })); | ||
canData.set.call(el, 'preventDataBindings', false); | ||
canData.set.call(el, 'viewModel', importPromise); | ||
canData.set.call(el, 'scope', importPromise); | ||
} | ||
} else { | ||
var frag = tagData.subtemplate ? tagData.subtemplate(scope, tagData.options) : DOCUMENT().createDocumentFragment(); | ||
var nodeList = nodeLists.register([], undefined, tagData.parentNodeList || true); | ||
nodeList.expression = '<' + this.tagName + '>'; | ||
events.one.call(el, 'removed', function () { | ||
nodeLists.unregister(nodeList); | ||
}); | ||
mutate.appendChild.call(el, frag); | ||
nodeLists.update(nodeList, getChildNodes(el)); | ||
} | ||
} | ||
[ | ||
'can-import', | ||
'can-dynamic-import' | ||
].forEach(function (tagName) { | ||
tag(tagName, processImport.bind({ tagName: tagName })); | ||
}); | ||
}(function () { | ||
return this; | ||
}(), require, exports, module)); | ||
}); | ||
/*[global-shim-end]*/ | ||
(function(global) { // jshint ignore:line | ||
global._define = global.define; | ||
global.define = global.define.orig; | ||
} | ||
)(typeof self == "object" && self.Object == Object ? self : window); |