@restnfeel/agentc-starter-kit
Version:
한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템
84 lines (69 loc) • 2.04 kB
JavaScript
import { __exports as nodes } from '../../../../_virtual/nodes.js';
import require$$0 from '../../../../_virtual/index-all.js';
var hasRequiredNodes;
function requireNodes () {
if (hasRequiredNodes) return nodes;
hasRequiredNodes = 1;
var _ = require$$0;
nodes.Element = Element;
nodes.element = function(name, attributes, children) {
return new Element(name, attributes, children);
};
nodes.text = function(value) {
return {
type: "text",
value: value
};
};
var emptyElement = nodes.emptyElement = {
first: function() {
return null;
},
firstOrEmpty: function() {
return emptyElement;
},
attributes: {},
children: []
};
function Element(name, attributes, children) {
this.type = "element";
this.name = name;
this.attributes = attributes || {};
this.children = children || [];
}
Element.prototype.first = function(name) {
return _.find(this.children, function(child) {
return child.name === name;
});
};
Element.prototype.firstOrEmpty = function(name) {
return this.first(name) || emptyElement;
};
Element.prototype.getElementsByTagName = function(name) {
var elements = _.filter(this.children, function(child) {
return child.name === name;
});
return toElementList(elements);
};
Element.prototype.text = function() {
if (this.children.length === 0) {
return "";
} else if (this.children.length !== 1 || this.children[0].type !== "text") {
throw new Error("Not implemented");
}
return this.children[0].value;
};
var elementListPrototype = {
getElementsByTagName: function(name) {
return toElementList(_.flatten(this.map(function(element) {
return element.getElementsByTagName(name);
}, true)));
}
};
function toElementList(array) {
return _.extend(array, elementListPrototype);
}
return nodes;
}
export { requireNodes as __require };
//# sourceMappingURL=nodes.js.map