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.1 to 0.0.2

compiler/build_nodes.js

219

collect_components.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : collect_components.js
* Created at : 2017-08-10
* Updated at : 2017-08-24
* Updated at : 2017-08-28
* Author : jeefo

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

// Polyfill {{{1
(function(constructor) {
if (! constructor.prototype.firstElementChild) {
Object.defineProperty(constructor.prototype, "firstElementChild", {
get : function () {
var node = this.firstChild;
while (node && 1 !== node.nodeType) { node = node.nextSibling; }
return node;
}
});
}
}(window.Node || window.Element));
var cache = require("./cache"),
parser = require("jeefo_template/parser"),
Directive = require("./directive"),
Component = require("./component"),
components = require("components"),
directives = require("directives"),
transcluder = require("./transcluder"),
combine_template, collect_components,
if (! ("nextElementSibling" in document.documentElement)) {
Object.defineProperty(Element.prototype, "nextElementSibling", {
get : function () {
var node = this.nextSibling;
while (node && node.nodeType !== 1) { node = node.nextSibling; }
return node;
}
});
}
// }}}1
var cache = require("./cache"),
parser = require("jeefo_template/parser"),
Directive = require("./directive"),
Component = require("./component"),
components = require("components"),
directives = require("directives"),
combine_template, collect_from_jeefo_nodes,
sort_by_priority = function (a, b) {

@@ -47,17 +24,15 @@ return b.definition.priority - a.definition.priority;

combine_attrs = function (attrs, other_attrs) {
var keys = other_attrs.keys, i = keys.length;
combine_pairs = function (pairs, other) {
var keys = other.keys, i = keys.length;
while (i--) {
attrs.set(keys[i], other_attrs.values[keys[i]]);
pairs.set(keys[i], other.values[keys[i]]);
}
return attrs;
return pairs;
},
combine_classes = function (class_list, other) {
var i = other.length;
while (i--) {
if (class_list.indexOf(other[i]) !== -1) {
class_list.push(other[i]);
}
combine_classes = function (class_list, other_list) {
for (var i = 0; i < other_list.length; ++i) {
class_list.add(other_list[i]);
}

@@ -68,86 +43,13 @@

find_transcluders = function (nodes, container) {
var i = nodes.length, j, keys, attrs;
while (i--) {
if (nodes[i].name === "jf-content") {
attrs = nodes[i].attrs;
keys = attrs.keys;
transclude = function (nodes, children) {
transcluder.find(nodes);
j = keys.length;
while (j--) {
if (keys[j] === "select") {
nodes[i].name = attrs.values[keys[j]];
}
}
container.push(nodes[i]);
} else {
find_transcluders(nodes[i].children, container);
}
for (var i = 0; i < children.length; ++i) {
transcluder.add_node(children[i]);
}
},
transcluder = function (node, other) {
if (! other.children.length) {
return;
}
var i = other.children.length,
children = node.children,
transcluders = [],
j, default_transcluder, nodes, index, transcluder;
node.children = other.children;
while (i--) {
other.children[i].parent = node;
}
find_transcluders(node.children, transcluders);
i = transcluders.length;
while (i--) {
if (transcluders[i].name === "jf-content") {
if (default_transcluder) {
throw new Error("Ambigious");
}
default_transcluder = transcluders[i];
transcluders.splice(i, 1);
}
}
i = transcluders.length;
while (i--) {
transcluder = transcluders[i];
nodes = [];
index = transcluder.parent.children.indexOf(transcluder);
j = children.length;
while (j--) {
if (children[j].name === transcluder.name) {
children[j].parent = transcluder.parent;
nodes.push(children[j]);
children.splice(j, 1);
}
}
transcluder.parent.children.splice.apply(
transcluder.parent.children,
[index, 1].concat(nodes)
);
}
i = children.length;
while (i--) {
children[i].parent = default_transcluder.parent;
}
index = default_transcluder.parent.children.indexOf(default_transcluder);
default_transcluder.parent.children.splice.apply(
default_transcluder.parent.children,
[index, 1].concat(children)
);
transcluder.transclude();
};
combine_template = function (template, node, container, counter) {
combine_template = function (template, node) {
if (typeof template === "function") {

@@ -159,13 +61,19 @@ template = template(node);

}
var nodes = parser(template), other = nodes[0];
collect_from_jeefo_nodes(nodes, container, parent, counter);
if (! node.id) {
node.id = other.id;
}
node.id = other.id;
node.attrs = combine_attrs(other.attrs, node.attrs);
node.class_list = combine_classes(other.class_list, node.class_list);
transcluder(node, other);
// Reason why other's property first is, we want keep other's order
node.attrs = combine_pairs(other.attrs, node.attrs);
node.events = combine_pairs(other.events, node.events);
node.class_list = combine_classes(other.class_list, node.class_list.list);
transclude(other.children, node.children);
node.children = other.children;
};
collect_from_jeefo_nodes = function (nodes, container, parent, counter) {
collect_components = function (nodes, container, parent, counter) {
var i = 0, component = new Component(parent), j, keys, attrs, _parent, directive;

@@ -183,3 +91,3 @@

if (component.definition.template) {
combine_template(component.definition.template, nodes[i], container, counter);
combine_template(component.definition.template, nodes[i]);
}

@@ -198,3 +106,3 @@ }

if (component.name || nodes[i].events.length || component.directives.length) {
if (component.name || nodes[i].events.keys.length || component.directives.length) {
counter.increment();

@@ -230,55 +138,6 @@

collect_from_jeefo_nodes(nodes[i].children, container, _parent, counter);
collect_components(nodes[i].children, container, _parent, counter);
}
};
exports.from_element = function collect_components (element, container, parent) {
var node = element.firstElementChild,
component = new Component(parent),
i, name, attrs, is_component;
while (node) {
name = node.tagName.toLowerCase();
is_component = false;
if (components[name]) {
is_component = true;
component.name = name;
component.definition = cache.resolve_component(name);
}
for (i = 0, attrs = node.attributes; i < attrs.length; ++i) {
name = attrs[i].name;
if (directives[name]) {
component.directives.push(new Directive(name, cache.resolve_directive(name)));
}
}
if (component.name || component.directives.length) {
component.element = node;
container[container.length] = component;
component = new Component();
}
if (! is_component) {
collect_components(node, container, parent);
}
node = node.nextElementSibling;
}
};
var compile_from_nodes = exports.from_nodes = function (nodes, container, parent, counter) {
var i = nodes.length, template = '';
collect_from_jeefo_nodes(nodes, container, parent, counter);
while (i--) {
template = nodes[i].compile() + template;
}
console.log(template);
return template;
};
exports.from_template = function (template, container, parent, counter) {
return compile_from_nodes(parser(template), container, parent, counter);
};
module.exports = collect_components;
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : component.js
* Created at : 2017-07-24
* Updated at : 2017-08-24
* Updated at : 2017-08-26
* Author : jeefo

@@ -50,5 +50,5 @@ * Purpose : Make possible to create a self contained web component.

$q = assign({}, require("jeefo_q")),
Events = require("jeefo_template/events"),
jqlite = require("jeefo_jqlite"),
parser = require("./parser"),
compiler = require("./compiler"),
$resource = require("jeefo_resource"),

@@ -122,6 +122,7 @@ $animator = require("jeefo_animate"),

var events = component.events,
$element = component.$element, i = events.length;
$element = component.$element,
names = events.keys, i = names.length;
while (i--) {
$element.on(events[i].name, parser(component, events[i].handler).getter());
$element.on(names[i], parser(component, events.values[names[i]]).getter());
}

@@ -206,3 +207,3 @@

this.parent = parent || null;
this.events = [];
this.events = new Events();
this.children = [];

@@ -209,0 +210,0 @@ this.directives = [];

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : counter.js
* Created at : 2017-08-12
* Updated at : 2017-08-12
* Updated at : 2017-08-26
* Author : jeefo

@@ -18,2 +18,2 @@ * Purpose :

module.exports = Counter;
module.exports = new Counter();
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : for_each_directive.js
* Created at : 2017-07-25
* Updated at : 2017-08-24
* Updated at : 2017-08-28
* Author : jeefo

@@ -12,4 +12,25 @@ * Purpose :

$animator = require("jeefo_animate"),
compile_nodes = require("./compiler").compile_nodes;
tokenizer = require("jeefo_javascript_parser/src/es5/tokenizer"),
compile_nodes = require("./compiler/nodes"),
parse_input = function (str) {
tokenizer.init(str);
var input = {}, token = tokenizer.next();
if (token.type === "Identifier") {
input.variable = token.name;
}
token = tokenizer.next();
if (token.name === "in") {
token = tokenizer.next();
}
if (token.type === "Identifier") {
input.input = token.name;
}
return input;
};
module.exports = {

@@ -20,9 +41,9 @@ priority : 1000,

on_init : function ($parser, $component) {
var $element = $component.$element;
var code = $component.attrs.values["for-each"],
input = parse_input(code),
$element = $component.$element;
this.$parser = $parser("tabs"); // hard coded
this.name = input.variable;
this.$parser = $parser(input.input);
this.$component = $component;
this.name = "tab"; // hard coded
this.code = $element[0].getAttribute("for-each");

@@ -33,3 +54,3 @@ // Clone dom tree

// Insert comment before remove $element
this.$comment = jqlite(document.createComment(" For each: " + this.code + ' '));
this.$comment = jqlite(document.createComment(" For each: " + code + ' '));
$element.before(this.$comment[0]);

@@ -89,4 +110,4 @@

$animator.enter(component.$element, stagger_index);
},
}
}
};
{
"name": "jeefo_component",
"version": "0.0.1",
"version": "0.0.2",
"description": "Part of jeefo framework",

@@ -19,23 +19,9 @@ "author": {

"keywords": [
"q",
"http",
"utils",
"jeefo",
"jqlite",
"promise",
"animate",
"template",
"tokenizer",
"directive",
"component",
"framework",
"resource",
"XMLHttpRequest"
"framework"
],
"devDependencies": {},
"dependencies": {
"jeefo_animate": "^0.0.1",
"jeefo_jqlite": "^0.0.1",
"jeefo_resource": "^0.0.1"
}
"dependencies": {},
"devDependencies": {}
}
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