Socket
Socket
Sign inDemoInstall

react-script

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-script - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

208

lib/react-script.js
// Generated by CoffeeScript 1.9.1
(function() {
var E, React, ref,
var E, React, add, hyphenate, is_plainish_object, ref,
slice = [].slice;

@@ -8,122 +8,108 @@

E = function() {
var add, args, attrArgs, childArgs, createElement, elementClass, hyphenate, is_plainish_object, selAttrs, selector, tagName;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
is_plainish_object = function(o) {
return (o != null) && typeof o === "object" && !((o.length != null) || React.isValidElement(o));
};
add = function(from, arg) {
var i, k, len, results, results1, thing, to, v;
to = arg.to;
if (from instanceof Array) {
results = [];
for (i = 0, len = from.length; i < len; i++) {
thing = from[i];
results.push(add(thing, {
to: to
}));
}
return results;
} else if (is_plainish_object(from)) {
results1 = [];
for (k in from) {
v = from[k];
if (v) {
results1.push(to.push(hyphenate(k)));
}
}
return results1;
} else if (from != null) {
return to.push(from);
is_plainish_object = function(o) {
return (o != null) && typeof o === "object" && !((o.length != null) || React.isValidElement(o));
};
add = function(from, arg) {
var i, k, len, results, results1, thing, to, v;
to = arg.to;
if (from instanceof Array) {
results = [];
for (i = 0, len = from.length; i < len; i++) {
thing = from[i];
results.push(add(thing, {
to: to
}));
}
};
hyphenate = function(v) {
return ("" + v).replace(/_/g, "-").replace(/([a-z])([A-Z])/g, function(m, az, AZ) {
return az + "-" + (AZ.toLowerCase());
});
};
createElement = function(elementType, arg) {
var addAttr, ak, attrArgs, av, childArgs, classNames, dk, dv, finalAttrs, finalChildren, selAttrs, selector, unhandled;
attrArgs = arg.attrArgs, childArgs = arg.childArgs, selAttrs = arg.selAttrs, selector = arg.selector;
finalAttrs = {};
classNames = [];
addAttr = function(ak, av) {
if (av !== false) {
return finalAttrs[ak] = av;
return results;
} else if (is_plainish_object(from)) {
results1 = [];
for (k in from) {
v = from[k];
if (v) {
results1.push(to.push(hyphenate(k)));
}
};
for (ak in attrArgs) {
av = attrArgs[ak];
if (ak === "class" || ak === "className" || ak === "classes" || ak === "classNames" || ak === "classList") {
add(av, {
to: classNames
});
} else if (ak === "data") {
for (dk in av) {
dv = av[dk];
addAttr("data-" + (hyphenate(dk)), dv);
}
} else if (ak.match(/^data|aria/)) {
addAttr(hyphenate(ak), av);
} else {
addAttr(ak, av);
}
}
if (selAttrs) {
unhandled = selAttrs.replace(/\.([a-z][a-z0-9\-_]*)/gi, function(m, className) {
classNames.push(className);
return "";
}).replace(/#([a-z][a-z0-9\-_]*)/gi, function(m, id) {
finalAttrs.id = id;
return "";
});
}
if (unhandled) {
throw new Error("Unhandled selector fragment '" + unhandled + "' in selector: '" + selector + "'");
}
if (classNames.length) {
finalAttrs.className = classNames.join(" ");
}
finalChildren = [];
add(childArgs, {
to: finalChildren
});
return React.createElement(elementType, finalAttrs, finalChildren);
};
if (args[0] == null) {
args[0] = "";
return results1;
} else if (from != null) {
return to.push(from);
}
switch (typeof args[0]) {
case "function":
if (is_plainish_object(args[1])) {
elementClass = args[0], attrArgs = args[1], childArgs = 3 <= args.length ? slice.call(args, 2) : [];
} else {
elementClass = args[0], childArgs = 2 <= args.length ? slice.call(args, 1) : [];
attrArgs = null;
}
return createElement(elementClass, {
attrArgs: attrArgs,
childArgs: childArgs
});
};
hyphenate = function(v) {
return ("" + v).replace(/_/g, "-").replace(/([a-z])([A-Z])/g, function(m, az, AZ) {
return az + "-" + (AZ.toLowerCase());
});
};
E = function() {
var addAttr, ak, args, attrArgs, av, childArgs, classNames, dk, dv, elementType, finalAttrs, finalChildren, selAttrs, selector, unhandled;
elementType = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
if (elementType == null) {
elementType = "";
}
if (is_plainish_object(args[0])) {
attrArgs = args[0], childArgs = 2 <= args.length ? slice.call(args, 1) : [];
} else {
childArgs = 1 <= args.length ? slice.call(args, 0) : [];
attrArgs = null;
}
switch (typeof elementType) {
case "string":
if (is_plainish_object(args[1])) {
selector = args[0], attrArgs = args[1], childArgs = 3 <= args.length ? slice.call(args, 2) : [];
} else {
selector = args[0], childArgs = 2 <= args.length ? slice.call(args, 1) : [];
attrArgs = null;
}
tagName = "div";
selector = elementType;
elementType = "div";
selAttrs = selector.replace(/^[a-z][a-z0-9\-_]*/i, function(match) {
tagName = match;
elementType = match;
return "";
});
return createElement(tagName, {
attrArgs: attrArgs,
childArgs: childArgs,
selAttrs: selAttrs,
selector: selector
});
break;
case "function":
break;
default:
throw new Error("Invalid first argument to ReactScript: " + args[0]);
throw new Error("Invalid first argument to ReactScript: " + elementType);
}
finalAttrs = {};
classNames = [];
addAttr = function(ak, av) {
if (av !== false) {
return finalAttrs[ak] = av;
}
};
for (ak in attrArgs) {
av = attrArgs[ak];
if (ak === "class" || ak === "className" || ak === "classes" || ak === "classNames" || ak === "classList") {
add(av, {
to: classNames
});
} else if (ak === "data") {
for (dk in av) {
dv = av[dk];
addAttr("data-" + (hyphenate(dk)), dv);
}
} else if (ak.match(/^data|aria/)) {
addAttr(hyphenate(ak), av);
} else {
addAttr(ak, av);
}
}
if (selAttrs) {
unhandled = selAttrs.replace(/\.([a-z][a-z0-9\-_]*)/gi, function(m, className) {
classNames.push(className);
return "";
}).replace(/#([a-z][a-z0-9\-_]*)/gi, function(m, id) {
finalAttrs.id = id;
return "";
});
}
if (unhandled) {
throw new Error("Unhandled selector fragment '" + unhandled + "' in selector: '" + selector + "'");
}
if (classNames.length) {
finalAttrs.className = classNames.join(" ");
}
finalChildren = [];
add(childArgs, {
to: finalChildren
});
return React.createElement(elementType, finalAttrs, finalChildren);
};

@@ -130,0 +116,0 @@

{
"name": "react-script",
"version": "1.2.0",
"version": "1.2.1",
"description": "Elegant DSL for React",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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