mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
23 lines
791 B
JavaScript
23 lines
791 B
JavaScript
var isBrowser = typeof window !== 'undefined';
|
|
var normalInclude = require('../../taglibs/core/include-tag');
|
|
var markoWidgets = require('../');
|
|
|
|
module.exports = function include(input, out) {
|
|
var target = input._target;
|
|
|
|
if (typeof target === 'string') {
|
|
out.text(target);
|
|
} else if (target) {
|
|
normalInclude(input, out);
|
|
} else if (isBrowser) {
|
|
var widgetId = input._widgetId;
|
|
|
|
// Thereis no body content so let's see if we should reuse
|
|
// the existing body content in the DOM
|
|
var existingEl = document.getElementById(widgetId);
|
|
if (existingEl) {
|
|
var widgetsContext = markoWidgets.getWidgetsContext(out);
|
|
widgetsContext.addPreservedDOMNode(existingEl, true /* body only */);
|
|
}
|
|
}
|
|
}; |