Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jeefo_component

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jeefo_component - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

template_cache.js

74

collect_components.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : collect_components.js
* Created at : 2017-08-10
* Updated at : 2017-09-14
* Updated at : 2017-09-20
* Author : jeefo

@@ -10,11 +10,11 @@ * Purpose :

var cache = require("./cache"),
parser = require("jeefo_template/parser"),
shived = {},
Directive = require("./directive"),
Component = require("./component"),
components = require("components"),
directives = require("directives"),
transcluder = require("./transcluder"),
combine_template, collect_components,
var $q = require("jeefo/q"),
cache = require("./cache"),
Directive = require("./directive"),
Component = require("./component"),
components = require("components"),
directives = require("directives"),
transcluder = require("./transcluder"),
template_resolver = require("./template_resolver"),
collect_components,

@@ -49,18 +49,29 @@ transclude = function (nodes, children) {

return result;
};
},
combine_template = function (template, node) {
if (typeof template === "function") {
template = template(node);
if (! template) {
return node;
make_template_resolver = function (nodes, i, container, _parent, counter) {
var node = nodes[i].clone();
nodes[i].clear();
return function (others) {
var local_promises = [];
if (node.children.length) {
transclude(others, node.children);
}
}
return parser(template);
node.children = others;
node.is_resolved = true;
collect_components([node], container, local_promises, _parent, counter);
return $q.all(local_promises).then(function () {
nodes[i] = node;
});
};
};
collect_components = function (nodes, container, parent, counter) {
collect_components = function (nodes, container, promises, parent, counter) {
var i = 0, component = new Component(parent),
j, keys, name, attrs, others, _parent, directive;
j, keys, name, attrs, others, promise, _parent, directive;

@@ -97,8 +108,17 @@ for (; i < nodes.length; ++i) {

if (component.definition.template) {
others = combine_template(component.definition.template, nodes[i]);
if (component.definition.template) {
others = template_resolver.resolve_template(component.definition.template, nodes[i]);
if (nodes[i] !== others) {
transclude(others, nodes[i].children);
nodes[i].children = others;
if (nodes[i] !== others) {
transclude(others, nodes[i].children);
nodes[i].children = others;
}
}
} else if (component.definition.template_url && ! nodes[i].is_resolved) {
promise = template_resolver.resolve_template_url(component.definition.template_url, nodes[i]).
then(make_template_resolver(nodes, i, container, parent, counter));
promises.push(promise);
component.name = null;
}

@@ -119,6 +139,2 @@ }

if (component.name && ! shived[component.name]) {
document.createElement(component.name);
shived[component.name] = true;
}
if (! nodes[i].name) {

@@ -146,3 +162,3 @@ nodes[i].name = component.name || "div";

collect_components(nodes[i].children, container, _parent, counter);
collect_components(nodes[i].children, container, promises, _parent, counter);
}

@@ -149,0 +165,0 @@ };

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : element.js
* Created at : 2017-08-26
* Updated at : 2017-08-31
* Updated at : 2017-09-20
* Author : jeefo

@@ -34,3 +34,4 @@ * Purpose :

var cache = require("../cache"),
var $q = require("jeefo/q"),
cache = require("../cache"),
jqlite = require("jeefo_jqlite"),

@@ -47,6 +48,22 @@ counter = require("../counter"),

collect_components_from_element = function (element, container, parent, counter) {
make_template_resolver = function (node, name, container, promises, parent, counter) {
var $old_element = jqlite(node), local_promises = [];
node = [ new NodeElement({ name : name }) ];
build_nodes(node[0], $old_element[0]);
collect_components(node, container, local_promises, parent, counter);
var promise = $q.all(local_promises).then(function () {
node = jqlite(node[0].compile('', ''))[0];
$old_element.replace_with(node);
});
promises.push(promise);
},
collect_components_from_element = function (element, container, promises, parent, counter) {
var node = element.firstElementChild,
component = new Component(parent),
i, name, attrs, match, _parent, $old_element;
i, name, attrs, match, _parent;

@@ -59,11 +76,3 @@ while (node) {

if (components[name]) {
$old_element = jqlite(node);
node = [ new NodeElement({ name : name }) ];
build_nodes(node[0], $old_element[0]);
collect_components(node, container, parent, counter);
node = jqlite(node[0].compile('', ''))[0];
$old_element.replace_with(node);
make_template_resolver(node, name, container, promises, parent, counter);
} else {

@@ -97,3 +106,3 @@ // Original node element

} else {
collect_components_from_element(node, container, parent, counter);
collect_components_from_element(node, container, promises, parent, counter);
}

@@ -106,21 +115,23 @@

module.exports = function compile_element (element, parent) {
var subcomponents = [];
var subcomponents = [], promises = [];
collect_components_from_element(element, subcomponents, parent, counter);
collect_components_from_element(element, subcomponents, promises, parent, counter);
var elements = element.querySelectorAll("[jeefo-component-id]"),
i = elements.length, map = {}, id;
$q.all(promises).then(function () {
var elements = element.querySelectorAll("[jeefo-component-id]"),
i = elements.length, map = {}, id;
while (i--) {
id = elements[i].getAttribute("jeefo-component-id");
map[id] = elements[i];
}
while (i--) {
id = elements[i].getAttribute("jeefo-component-id");
map[id] = elements[i];
}
// Compile subdirectives
for (i = 0; i < subcomponents.length; ++i) {
id = subcomponents[i].id;
subcomponents[i].element = map[id];
// Compile subdirectives
for (i = 0; i < subcomponents.length; ++i) {
id = subcomponents[i].id;
subcomponents[i].element = map[id];
subcomponents[i].compile();
}
subcomponents[i].compile();
}
});
};
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : nodes.js
* Created at : 2017-08-26
* Updated at : 2017-08-26
* Updated at : 2017-09-20
* Author : jeefo

@@ -10,16 +10,10 @@ * Purpose :

var jqlite = require("jeefo_jqlite"),
var $q = require("jeefo/q"),
jqlite = require("jeefo_jqlite"),
counter = require("../counter"),
collect_components = require("../collect_components");
/**
* @doc
* @param template : jeefo template string.
* @param parent : parent directive object.
* @return Document fragment object
*/
module.exports = function compile_nodes (nodes, parent) {
var i = nodes.length, fragment = document.createDocumentFragment(), subcomponents = [], template = '';
var compile_fragment = function (nodes, subcomponents) {
var i = nodes.length, fragment = document.createDocumentFragment(), template = '';
collect_components(nodes, subcomponents, parent, counter);
while (i--) {

@@ -49,1 +43,17 @@ template = nodes[i].compile('', '') + template;

};
/**
* @doc
* @param template : jeefo template string.
* @param parent : parent directive object.
* @return Document fragment object
*/
module.exports = function compile_nodes (nodes, parent) {
var promises = [], subcomponents = [];
collect_components(nodes, subcomponents, promises, parent, counter);
return $q.all(promises).then(function () {
return compile_fragment(nodes, subcomponents);
});
};
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : for_each_directive.js
* Created at : 2017-07-25
* Updated at : 2017-09-19
* Updated at : 2017-09-20
* Author : jeefo

@@ -89,18 +89,20 @@ * Purpose :

create_component : function (index, value, stagger_index) {
var node = this.node.clone(),
component = this.$component.inherit();
var self = this,
node = self.node.clone(),
component = self.$component.inherit();
component.controller = { $index : index };
component.controller_as = this.name;
component.controller[this.$input.name] = value;
component.controller_as = self.name;
component.controller[self.$input.name] = value;
var element = compile_nodes([node], component).firstChild;
component.$element = jqlite(element);
compile_nodes([node], component).then(function (fragment) {
component.$element = jqlite(fragment.firstChild);
this.$component.children[index] = component;
this.$last_element.after(element);
self.$component.children[index] = component;
self.$last_element.after(fragment);
$animator.enter(component.$element, stagger_index);
$animator.enter(component.$element, stagger_index);
this.$children.push(component);
self.$children.push(component);
});
},

@@ -107,0 +109,0 @@ on_render : function () {

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : if_directive.js
* Created at : 2017-09-17
* Updated at : 2017-09-19
* Updated at : 2017-09-20
* Author : jeefo

@@ -59,10 +59,10 @@ * Purpose :

create_component : function () {
var node = this.node.clone();
var node = this.node.clone(),
comment = this.$comment,
child_component = this.$child_component = this.$component.inherit();
this.$child_component = this.$component.inherit();
var element = compile_nodes([node], this.$child_component).firstChild;
this.$comment.after(element);
this.$child_component.trigger_render();
compile_nodes([node], this.$child_component).then(function (fragment) {
comment.after(fragment);
child_component.trigger_render();
});
},

@@ -69,0 +69,0 @@ on_render : function () {

{
"name": "jeefo_component",
"version": "0.0.10",
"version": "0.0.11",
"description": "Part of jeefo framework",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc