New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

better-emmet-plugin

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-emmet-plugin - npm Package Compare versions

Comparing version 0.10.1 to 1.0.0-beta.1

2

bower.json
{
"name": "better-emmet-plugin",
"version": "0.9.0",
"version": "1.0.0-beta.0",
"main": [

@@ -5,0 +5,0 @@ "dist/better-emmet-plugin.js"

/**
* better-emmet-plugin: Emmet abbreviation parser for better-dom
* @version 0.10.1 Wed, 27 Jan 2016 08:31:47 GMT
* @version 1.0.0-beta.1 Sun, 03 Apr 2016 13:38:44 GMT
* @link https://github.com/chemerisuk/better-emmet-plugin#readme

@@ -14,5 +14,5 @@ * @copyright 2016 Maksim Chemerisuk

var // operator type / priority object
operators = { "(": 1, ")": 2, "^": 3, ">": 4, "+": 5, "*": 6, "`": 7, "[": 8, ".": 8, "#": 8 },
reParse = /`[^`]*`|\[[^\]]*\]|\.[^()>^+*`[#]+|[^()>^+*`[#.]+|\^+|./g,
reAttr = /\s*([\w\-]+)(?:=((?:`([^`]*)`)|[^\s]*))?/g,
operators = { "(": 1, ")": 2, ">": 3, "+": 4, "*": 5, "{": 6, "[": 7, ".": 7, "#": 7 },
reParse = /\{[^\}]*\}|\[[^\]]*\]|\.[^()>^+*\{[#]+|[^()>^+*\{[#.]+|\^+|./g,
reAttr = /\s*([\w\-]+)(?:=((?:("|')(\\?.)*?\3)|[^\s]*))?/g,
reIndex = /(\$+)(?:@(-)?(\d+)?)?/g,

@@ -22,15 +22,14 @@ reDot = /\./g,

tagCache = { "": "" },
normalizeAttrs = function (_, name, value, rawValue) {
// try to detemnie which kind of quotes to use
var quote = value && value.indexOf("\"") >= 0 ? "'" : "\"";
if (typeof rawValue === "string") {
// grab unquoted value for smart quotes
value = rawValue;
} else if (typeof value !== "string") {
// handle boolean attributes by using name as value
normalizeAttrs = function (_, name, value, quote) {
if (value === void 0) {
// handle boolean attributes
value = name;
}
// always wrap attribute values with quotes even they don't exist
return " " + name + "=" + quote + value + quote;
if (quote === void 0) {
// wrap value with quotes if they do not exist
value = "\"" + value + "\"";
}
return " " + name + "=" + value;
},

@@ -83,5 +82,2 @@ injectTerm = function (term, end) {

* DOM.emmet("ul>li*2"); // => '<ul><li></li><li></li></ul>'
* DOM.emmet("b>`hello {user}`", {user: "world"}); // => '<b>hello world</b>'
* DOM.emmet("i.{0}+span", ["icon"]); // => '<i class="icon"></i><span></span>'
* DOM.emmet("i.{a}>span#{b}", {a: "foo", b: "bar"}); // => '<i class="foo"><span id="bar"></span></i>'
*/

@@ -105,11 +101,4 @@ DOM.emmet = function (template) {

if (str !== "(") {
// for ^ operator need to skip > str.length times
for (var _i = 0, n = op === "^" ? str.length : 1; _i < n; ++_i) {
while (stack[0] !== op && operators[stack[0]] >= priority) {
var head = stack.shift();
output.push(head);
// for ^ operator stop shifting when the first > is found
if (op === "^" && head === ">") break;
}
while (stack[0] !== op && operators[stack[0]] >= priority) {
output.push(stack.shift());
}

@@ -121,4 +110,4 @@ }

} else {
// handle values inside of `...` and [...] sections
if (op === "[" || op === "`") {
// handle values inside of {...} and [...] sections
if (op === "[" || op === "{") {
output.push(str.slice(1, -1));

@@ -145,5 +134,5 @@ }

for (var j = 0; j < output.length; ++j) {
var str = output[j];
var _str = output[j];
if (str in operators) {
if (_str in operators) {
var value = stack.shift();

@@ -156,3 +145,3 @@ var node = stack.shift();

switch (str) {
switch (_str) {
case ".":

@@ -174,3 +163,3 @@ value = injectTerm(" class=\"" + value + "\"");

case "`":
case "{":
stack.unshift(node);

@@ -184,6 +173,6 @@ // escape unsafe HTML symbols

default:
/* ">", "+", "^" */
/* ">", "+" */
value = typeof value === "string" ? makeTerm(value) : value.join("");
if (str === ">") {
if (_str === ">") {
value = injectTerm(value, true);

@@ -195,6 +184,6 @@ } else {

str = typeof value === "function" ? node.map(value) : node;
_str = typeof value === "function" ? node.map(value) : node;
}
stack.unshift(str);
stack.unshift(_str);
}

@@ -201,0 +190,0 @@

/**
* better-emmet-plugin: Emmet abbreviation parser for better-dom
* @version 0.10.1 Wed, 27 Jan 2016 08:31:47 GMT
* @version 1.0.0-beta.1 Sun, 03 Apr 2016 13:38:44 GMT
* @link https://github.com/chemerisuk/better-emmet-plugin#readme

@@ -8,2 +8,2 @@ * @copyright 2016 Maksim Chemerisuk

*/
!function(e){"use strict";var r={"(":1,")":2,"^":3,">":4,"+":5,"*":6,"`":7,"[":8,".":8,"#":8},t=/`[^`]*`|\[[^\]]*\]|\.[^()>^+*`[#]+|[^()>^+*`[#.]+|\^+|./g,n=/\s*([\w\-]+)(?:=((?:`([^`]*)`)|[^\s]*))?/g,i=/(\$+)(?:@(-)?(\d+)?)?/g,a=/\./g,f=/\$/g,s={"":""},c=function(e,r,t,n){var i=t&&t.indexOf('"')>=0?"'":'"';return"string"==typeof n?t=n:"string"!=typeof t&&(t=r)," "+r+"="+i+t+i},o=function(e,r){return function(t){var n=r?t.lastIndexOf("<"):t.indexOf(">");return t.slice(0,n)+e+t.slice(n)}},u=function(e){return s[e]||(s[e]="<"+e+"></"+e+">")},l=function(e,r){var t,n=Array(e);for(t=0;e>t;++t)n[t]=r.replace(i,function(r,n,i,a){var s=(i?e-t-1:t)+(a?+a:1);return(n+s).slice(-n.length).replace(f,"0")});return n},p=/[&<>"']/g,h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};"area base br col hr img input link meta param command keygen source".split(" ").forEach(function(e){s[e]="<"+e+">"}),e.emmet=function(e){if("string"!=typeof e)throw new TypeError("template");if(e in s)return s[e];for(var i=[],f=[],g=0,v=e.match(t);g<v.length;++g){var m=v[g],y=m[0],b=r[y];if(b){if("("!==m)for(var d=0,k="^"===y?m.length:1;k>d;++d)for(;i[0]!==y&&r[i[0]]>=b;){var w=i.shift();if(f.push(w),"^"===y&&">"===w)break}")"===m?i.shift():(("["===y||"`"===y)&&f.push(m.slice(1,-1)),"."===y&&f.push(m.slice(1).replace(a," ")),i.unshift(y))}else f.push(m)}f=f.concat(i),i=[];for(var O=0;O<f.length;++O){var m=f[O];if(m in r){var j=i.shift(),x=i.shift();switch("string"==typeof x&&(x=[u(x)]),m){case".":j=o(' class="'+j+'"');break;case"#":j=o(' id="'+j+'"');break;case"[":j=o(j.replace(n,c));break;case"*":x=l(+j,x.join(""));break;case"`":i.unshift(x),x=[j.replace(p,function(e){return h[e]})];break;default:j="string"==typeof j?u(j):j.join(""),">"===m?j=o(j,!0):x.push(j)}m="function"==typeof j?x.map(j):x}i.unshift(m)}return f=1===f.length?u(i[0]):i[0].join("")}}(window.DOM);
!function(e){"use strict";var r={"(":1,")":2,">":3,"+":4,"*":5,"{":6,"[":7,".":7,"#":7},n=/\{[^\}]*\}|\[[^\]]*\]|\.[^()>^+*\{[#]+|[^()>^+*\{[#.]+|\^+|./g,t=/\s*([\w\-]+)(?:=((?:("|')(\\?.)*?\3)|[^\s]*))?/g,i=/(\$+)(?:@(-)?(\d+)?)?/g,a=/\./g,s=/\$/g,c={"":""},f=function(e,r,n,t){return void 0===n&&(n=r),void 0===t&&(n='"'+n+'"')," "+r+"="+n},o=function(e,r){return function(n){var t=r?n.lastIndexOf("<"):n.indexOf(">");return n.slice(0,t)+e+n.slice(t)}},u=function(e){return c[e]||(c[e]="<"+e+"></"+e+">")},l=function(e,r){var n,t=Array(e);for(n=0;e>n;++n)t[n]=r.replace(i,function(r,t,i,a){var c=(i?e-n-1:n)+(a?+a:1);return(t+c).slice(-t.length).replace(s,"0")});return t},h=/[&<>"']/g,p={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};"area base br col hr img input link meta param command keygen source".split(" ").forEach(function(e){c[e]="<"+e+">"}),e.emmet=function(e){if("string"!=typeof e)throw new TypeError("template");if(e in c)return c[e];for(var i=[],s=[],g=0,m=e.match(n);g<m.length;++g){var v=m[g],d=v[0],b=r[d];if(b){if("("!==v)for(;i[0]!==d&&r[i[0]]>=b;)s.push(i.shift());")"===v?i.shift():("["!==d&&"{"!==d||s.push(v.slice(1,-1)),"."===d&&s.push(v.slice(1).replace(a," ")),i.unshift(d))}else s.push(v)}s=s.concat(i),i=[];for(var k=0;k<s.length;++k){var y=s[k];if(y in r){var w=i.shift(),j=i.shift();switch("string"==typeof j&&(j=[u(j)]),y){case".":w=o(' class="'+w+'"');break;case"#":w=o(' id="'+w+'"');break;case"[":w=o(w.replace(t,f));break;case"*":j=l(+w,j.join(""));break;case"{":i.unshift(j),j=[w.replace(h,function(e){return p[e]})];break;default:w="string"==typeof w?u(w):w.join(""),">"===y?w=o(w,!0):j.push(w)}y="function"==typeof w?j.map(w):j}i.unshift(y)}return s=1===s.length?u(i[0]):i[0].join("")}}(window.DOM);
{
"name": "better-emmet-plugin",
"version": "0.10.1",
"version": "1.0.0-beta.1",
"description": "Emmet abbreviation parser for better-dom",

@@ -19,4 +19,3 @@ "main": "dist/better-emmet-plugin.js",

"start": "gulp dev $npm_package_config_gulp",
"preversion": "npm test",
"version": "gulp npm-dist $npm_package_config_gulp",
"version": "gulp dist $npm_package_config_gulp",
"postversion": "git push && git push --tags"

@@ -23,0 +22,0 @@ },

# better-emmet-plugin<br>[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Bower version][bower-image]][bower-url]
> Emmet abbreviation parser for [better-dom](https://github.com/chemerisuk/better-dom)
## Differences from emmet.io parser
1. Element aliases are not supported
2. Implied tag names are not supported
3. `a{text}` instead of `a>{text}` is not supported
4. Operator `^` is not supported
5. Expandos are not supported
6. Boolean attributes (attributes are boolean by default)
7. Default attributes are not supported
8. Short tags are not supported
## Browser support

@@ -5,0 +15,0 @@ #### Desktop

@@ -7,5 +7,5 @@ (function(DOM) {

var // operator type / priority object
operators = {"(": 1,")": 2,"^": 3,">": 4,"+": 5,"*": 6,"`": 7,"[": 8,".": 8,"#": 8},
reParse = /`[^`]*`|\[[^\]]*\]|\.[^()>^+*`[#]+|[^()>^+*`[#.]+|\^+|./g,
reAttr = /\s*([\w\-]+)(?:=((?:`([^`]*)`)|[^\s]*))?/g,
operators = {"(": 1,")": 2,">": 3,"+": 4,"*": 5,"{": 6,"[": 7,".": 7,"#": 7},
reParse = /\{[^\}]*\}|\[[^\]]*\]|\.[^()>^+*\{[#]+|[^()>^+*\{[#.]+|\^+|./g,
reAttr = /\s*([\w\-]+)(?:=((?:("|')(\\?.)*?\3)|[^\s]*))?/g,
reIndex = /(\$+)(?:@(-)?(\d+)?)?/g,

@@ -15,15 +15,14 @@ reDot = /\./g,

tagCache = {"": ""},
normalizeAttrs = (_, name, value, rawValue) => {
// try to detemnie which kind of quotes to use
var quote = value && value.indexOf("\"") >= 0 ? "'" : "\"";
if (typeof rawValue === "string") {
// grab unquoted value for smart quotes
value = rawValue;
} else if (typeof value !== "string") {
// handle boolean attributes by using name as value
normalizeAttrs = (_, name, value, quote) => {
if (value === void 0) {
// handle boolean attributes
value = name;
}
// always wrap attribute values with quotes even they don't exist
return " " + name + "=" + quote + value + quote;
if (quote === void 0) {
// wrap value with quotes if they do not exist
value = `"${value}"`;
}
return " " + name + "=" + value;
},

@@ -37,3 +36,3 @@ injectTerm = (term, end) => (html) => {

makeTerm = (tag) => {
return tagCache[tag] || (tagCache[tag] = "<" + tag + "></" + tag + ">");
return tagCache[tag] || (tagCache[tag] = `<${tag}></${tag}>`);
},

@@ -59,3 +58,3 @@ makeIndexedTerm = (n, term) => {

"area base br col hr img input link meta param command keygen source".split(" ").forEach((tag) => {
tagCache[tag] = "<" + tag + ">";
tagCache[tag] = `<${tag}>`;
});

@@ -74,5 +73,2 @@

* DOM.emmet("ul>li*2"); // => '<ul><li></li><li></li></ul>'
* DOM.emmet("b>`hello {user}`", {user: "world"}); // => '<b>hello world</b>'
* DOM.emmet("i.{0}+span", ["icon"]); // => '<i class="icon"></i><span></span>'
* DOM.emmet("i.{a}>span#{b}", {a: "foo", b: "bar"}); // => '<i class="foo"><span id="bar"></span></i>'
*/

@@ -95,11 +91,4 @@ DOM.emmet = function(template) {

if (str !== "(") {
// for ^ operator need to skip > str.length times
for (let i = 0, n = (op === "^" ? str.length : 1); i < n; ++i) {
while (stack[0] !== op && operators[stack[0]] >= priority) {
let head = stack.shift();
output.push(head);
// for ^ operator stop shifting when the first > is found
if (op === "^" && head === ">") break;
}
while (stack[0] !== op && operators[stack[0]] >= priority) {
output.push(stack.shift());
}

@@ -111,4 +100,4 @@ }

} else {
// handle values inside of `...` and [...] sections
if (op === "[" || op === "`") {
// handle values inside of {...} and [...] sections
if (op === "[" || op === "{") {
output.push(str.slice(1, -1));

@@ -147,7 +136,7 @@ }

case ".":
value = injectTerm(" class=\"" + value + "\"");
value = injectTerm(` class="${value}"`);
break;
case "#":
value = injectTerm(" id=\"" + value + "\"");
value = injectTerm(` id="${value}"`);
break;

@@ -163,3 +152,3 @@

case "`":
case "{":
stack.unshift(node);

@@ -170,3 +159,3 @@ // escape unsafe HTML symbols

default: /* ">", "+", "^" */
default: /* ">", "+" */
value = typeof value === "string" ? makeTerm(value) : value.join("");

@@ -173,0 +162,0 @@

describe("DOM.emmet", function() {
"use strict";
/* jshint quotmark:false */
function checkExpr(source, target, vars) {

@@ -10,11 +12,12 @@ it(source, function() {

checkExpr("", "");
checkExpr("article", "<article></article>");
checkExpr("", ""); // new
checkExpr("article", "<article></article>"); // new
describe("'+' operator", function() {
describe("Operator +", function() {
checkExpr("p+p", "<p></p><p></p>");
checkExpr("p+P", "<p></p><P></P>");
checkExpr("p.name+p+p", "<p class=\"name\"></p><p></p><p></p>");
});
describe("'>' operator", function() {
describe("Operator >", function() {
checkExpr("p>em", "<p><em></em></p>");

@@ -26,93 +29,65 @@ checkExpr("ul>li>a", "<ul><li><a></a></li></ul>");

describe("'^' operator", function() {
checkExpr("p>em^div", "<p><em></em></p><div></div>");
checkExpr("p>em>span^b", "<p><em><span></span></em><b></b></p>");
checkExpr("p>em>span+i^b", "<p><em><span></span><i></i></em><b></b></p>");
checkExpr("p>em>span^^div", "<p><em><span></span></em></p><div></div>");
checkExpr("p>em>span^^^^div", "<p><em><span></span></em></p><div></div>");
});
describe('Attributes', function() {
checkExpr("a[]", "<a></a>"); // new
checkExpr('p.name', '<p class="name"></p>');
checkExpr('p.one.two.three', '<p class="one two three"></p>');
checkExpr('p.one-two.three', '<p class="one-two three"></p>');
checkExpr('p.one.two-three', '<p class="one two-three"></p>');
checkExpr('p.one_two-three', '<p class="one_two-three"></p>');
checkExpr('p#myid', '<p id="myid"></p>');
checkExpr('p#myid.name_with-dash32.otherclass', '<p id="myid" class="name_with-dash32 otherclass"></p>');
checkExpr('span.one.two.three', '<span class="one two three"></span>');
describe("classes", function() {
checkExpr("p.name", "<p class=\"name\"></p>");
checkExpr("p.one.two.three", "<p class=\"one two three\"></p>");
checkExpr("p.one.two-three", "<p class=\"one two-three\"></p>");
checkExpr("p.one_two-three", "<p class=\"one_two-three\"></p>");
});
checkExpr('span.one#two', '<span class="one" id="two"></span>');
checkExpr('span.one.two#three', '<span class="one two" id="three"></span>');
describe("id", function() {
checkExpr("p#myid", "<p id=\"myid\"></p>");
checkExpr("p#myid.name_with-dash32.otherclass", "<p id=\"myid\" class=\"name_with-dash32 otherclass\"></p>");
checkExpr("span#three.one.two", "<span id=\"three\" class=\"one two\"></span>");
checkExpr("span.one.two#three", "<span class=\"one two\" id=\"three\"></span>");
checkExpr('span[title]', '<span title="title"></span>'); // diff
checkExpr('span[title data]', '<span title="title" data="data"></span>'); // diff
checkExpr('span.test[title data]', '<span class="test" title="title" data="data"></span>'); // diff
checkExpr('span#one.two[title data]', '<span id="one" class="two" title="title" data="data"></span>'); // diff
checkExpr('span[title=Hello]', '<span title="Hello"></span>');
checkExpr('span[title="Hello world"]', '<span title="Hello world"></span>');
checkExpr('span[title=\'Hello world\']', '<span title=\'Hello world\'></span>'); // diff
checkExpr('span[title="Hello world" data=other]', '<span title="Hello world" data="other"></span>');
checkExpr('span[title="Hello world" data=other attr2 attr3]', '<span title="Hello world" data="other" attr2="attr2" attr3="attr3"></span>'); // diff
checkExpr('span[title="Hello world" data=other attr2 attr3]>em', '<span title="Hello world" data="other" attr2="attr2" attr3="attr3"><em></em></span>'); //diff
checkExpr('filelist[id=javascript.files]', '<filelist id="javascript.files"></filelist>');
});
describe("attributes", function() {
checkExpr("a[]", "<a></a>");
checkExpr("a[title]", "<a title=\"title\"></a>");
checkExpr("a[title href]", "<a title=\"title\" href=\"href\"></a>");
checkExpr("a.test[title href]", "<a class=\"test\" title=\"title\" href=\"href\"></a>");
checkExpr("a.test[title href]", "<a class=\"test\" title=\"title\" href=\"href\"></a>");
checkExpr("a#one.two[title href]", "<a id=\"one\" class=\"two\" title=\"title\" href=\"href\"></a>");
checkExpr("a[title=hello]", "<a title=\"hello\"></a>");
checkExpr("a[title=`hello world`]", "<a title=\"hello world\"></a>");
checkExpr("a[title=`{\"hello\":\"world\"}`]", "<a title='{\"hello\":\"world\"}'></a>");
checkExpr("a[title=`hello world` href=other]", "<a title=\"hello world\" href=\"other\"></a>");
checkExpr("a[title=`hello world` href=other name]", "<a title=\"hello world\" href=\"other\" name=\"name\"></a>");
checkExpr("a[title=`hello world` href=other name]>em", "<a title=\"hello world\" href=\"other\" name=\"name\"><em></em></a>");
checkExpr("section[id=javascript.files]", "<section id=\"javascript.files\"></section>");
checkExpr("a[b c=`d'f`]", "<a b=\"b\" c=\"d'f\"></a>");
checkExpr("a[b c=`d\"f`]", "<a b=\"b\" c='d\"f'></a>");
checkExpr("input[type=text disabled]", "<input type=\"text\" disabled=\"disabled\">");
checkExpr("a[href=b c]", "<a href=\"b\" c=\"c\"></a>");
checkExpr("table[a=b].days>tr>td[c=d]*2", "<table a=\"b\" class=\"days\"><tr><td c=\"d\"></td><td c=\"d\"></td></tr></table>");
checkExpr("table.days[a=b]>tr>td[c=d]*2", "<table class=\"days\" a=\"b\"><tr><td c=\"d\"></td><td c=\"d\"></td></tr></table>");
describe('Counters', function() {
checkExpr('ul#nav>li.item$*3', '<ul id="nav"><li class="item1"></li><li class="item2"></li><li class="item3"></li></ul>');
checkExpr('ul#nav>li.item$$$*3', '<ul id="nav"><li class="item001"></li><li class="item002"></li><li class="item003"></li></ul>');
checkExpr('ul#nav>li.$$item$$$*3', '<ul id="nav"><li class="01item001"></li><li class="02item002"></li><li class="03item003"></li></ul>');
checkExpr('ul#nav>li.pre$*3+li.post$*3', '<ul id="nav"><li class="pre1"></li><li class="pre2"></li><li class="pre3"></li><li class="post1"></li><li class="post2"></li><li class="post3"></li></ul>');
checkExpr('div.sample$*3', '<div class="sample1"></div><div class="sample2"></div><div class="sample3"></div>'); // diff
checkExpr('ul#nav>(li>{text})*3', '<ul id="nav"><li>text</li><li>text</li><li>text</li></ul>'); // diff
// test counter base
checkExpr('{$@3 }*3', '3 4 5 ');
checkExpr('{$@- }*3', '3 2 1 ');
checkExpr('{$@-5 }*3', '7 6 5 ');
});
describe("variables", function() {
checkExpr("ul#nav>li.item$*3", "<ul id=\"nav\"><li class=\"item1\"></li><li class=\"item2\"></li><li class=\"item3\"></li></ul>");
checkExpr("ul#nav>li.item$$$*3", "<ul id=\"nav\"><li class=\"item001\"></li><li class=\"item002\"></li><li class=\"item003\"></li></ul>");
checkExpr("ul#nav>li.$$item$$$*3", "<ul id=\"nav\"><li class=\"01item001\"></li><li class=\"02item002\"></li><li class=\"03item003\"></li></ul>");
checkExpr("ul#nav>li.pre$*3+li.post$*3", "<ul id=\"nav\"><li class=\"pre1\"></li><li class=\"pre2\"></li><li class=\"pre3\"></li><li class=\"post1\"></li><li class=\"post2\"></li><li class=\"post3\"></li></ul>");
checkExpr("div.sample$*3", "<div class=\"sample1\"></div><div class=\"sample2\"></div><div class=\"sample3\"></div>");
checkExpr("li#id$.class$*3", "<li id=\"id1\" class=\"class1\"></li><li id=\"id2\" class=\"class2\"></li><li id=\"id3\" class=\"class3\"></li>");
checkExpr("ul>(li>b)*3", "<ul><li><b></b></li><li><b></b></li><li><b></b></li></ul>");
checkExpr("ul>li*3>b", "<ul><li><b></b></li><li><b></b></li><li><b></b></li></ul>");
checkExpr("a>`{c}`", "<a>{c}</a>");
checkExpr("a>`test`", "<a>test</a>");
checkExpr("a.test>`test`", "<a class=\"test\">test</a>");
checkExpr("a#bbb>`test`", "<a id=\"bbb\">test</a>");
checkExpr("div[class=foo-en]*2", "<div class=\"foo-en\"></div><div class=\"foo-en\"></div>");
checkExpr("div[class=foo-$lang]*2", "<div class=\"foo-1lang\"></div><div class=\"foo-2lang\"></div>");
checkExpr("i>``", "<i></i>");
checkExpr("i>`:`", "<i>:</i>");
checkExpr("i>span+``", "<i><span></span></i>");
checkExpr("i>``+span", "<i><span></span></i>");
checkExpr("a[b=]>`test`", "<a b=\"\">test</a>");
checkExpr("a[b=``]>`test`", "<a b=\"\">test</a>");
describe('Groups', function() {
checkExpr('div#head+(p>p)+div#footer', '<div id="head"></div><p><p></p></p><div id="footer"></div>');
checkExpr('div#head>((ul#nav>li*3)+(div.subnav>p)+(div.othernav))+div#footer', '<div id="head"><ul id="nav"><li></li><li></li><li></li></ul><div class="subnav"><p></p></div><div class="othernav"></div><div id="footer"></div></div>');
checkExpr('div#head>(ul#nav>li*3>(div.subnav>p)+(div.othernav))+div#footer', '<div id="head"><ul id="nav"><li><div class="subnav"><p></p></div><div class="othernav"></div></li><li><div class="subnav"><p></p></div><div class="othernav"></div></li><li><div class="subnav"><p></p></div><div class="othernav"></div></li></ul><div id="footer"></div></div>');
checkExpr('ul>li.pre$*2+(li.item$*4>a)+li.post$*2', '<ul><li class="pre1"></li><li class="pre2"></li><li class="item1"><a></a></li><li class="item2"><a></a></li><li class="item3"><a></a></li><li class="item4"><a></a></li><li class="post1"></li><li class="post2"></li></ul>'); // diff
checkExpr('div>(i+b)*2+(span+em)*3', '<div><i></i><b></b><i></i><b></b><span></span><em></em><span></span><em></em><span></span><em></em></div>');
});
describe("groups", function() {
checkExpr("div#head+(p>span)+div#footer", "<div id=\"head\"></div><p><span></span></p><div id=\"footer\"></div>");
checkExpr("div#head>((ul#nav>li*3)+(div.subnav>p)+(div.othernav))+div#footer", "<div id=\"head\"><ul id=\"nav\"><li></li><li></li><li></li></ul><div class=\"subnav\"><p></p></div><div class=\"othernav\"></div><div id=\"footer\"></div></div>");
checkExpr("div#head>(ul#nav>li*3>(div.subnav>p)+(div.othernav))+div#footer", "<div id=\"head\"><ul id=\"nav\"><li><div class=\"subnav\"><p></p></div><div class=\"othernav\"></div></li><li><div class=\"subnav\"><p></p></div><div class=\"othernav\"></div></li><li><div class=\"subnav\"><p></p></div><div class=\"othernav\"></div></li></ul><div id=\"footer\"></div></div>");
checkExpr("ul>li.pre$*2+(li.item$*4>a)+li.post$*2", "<ul><li class=\"pre1\"></li><li class=\"pre2\"></li><li class=\"item1\"><a></a></li><li class=\"item2\"><a></a></li><li class=\"item3\"><a></a></li><li class=\"item4\"><a></a></li><li class=\"post1\"></li><li class=\"post2\"></li></ul>");
checkExpr("div>(i+b)*2+(span+em)*3", "<div><i></i><b></b><i></i><b></b><span></span><em></em><span></span><em></em><span></span><em></em></div>");
checkExpr("(span.i$)*3", "<span class=\"i1\"></span><span class=\"i2\"></span><span class=\"i3\"></span>");
// checkExpr("(p.i$+ul>li.i$*2>span.s$)*3", "<p class=\"i1\"></p><ul><li class=\"i1\"><span class=\"s1\"></span></li><li class=\"i2\"><span class=\"s2\"></span></li></ul><p class=\"i2\"></p><ul><li class=\"i1\"><span class=\"s1\"></span></li><li class=\"i2\"><span class=\"s2\"></span></li></ul><p class=\"i3\"></p><ul><li class=\"i1\"><span class=\"s1\"></span></li><li class=\"i2\"><span class=\"s2\"></span></li></ul>");
checkExpr("p.p$*2>(i.i$+b.b$)*3", "<p class=\"p1\"><i class=\"i1\"></i><b class=\"b1\"></b><i class=\"i2\"></i><b class=\"b2\"></b><i class=\"i3\"></i><b class=\"b3\"></b></p><p class=\"p2\"><i class=\"i1\"></i><b class=\"b1\"></b><i class=\"i2\"></i><b class=\"b2\"></b><i class=\"i3\"></i><b class=\"b3\"></b></p>");
// checkExpr("a.c[d=$@2]*3>b>`Card $@-5`", "<a class=\"c\" d=\"2\"><b>Card 7</b></a><a class=\"c\" d=\"3\"><b>Card 6</b></a><a class=\"c\" d=\"4\"><b>Card 5</b></a>");
checkExpr("(a.c[d=$@2]>b>`Card $@-5`)*3", "<a class=\"c\" d=\"2\"><b>Card 7</b></a><a class=\"c\" d=\"3\"><b>Card 6</b></a><a class=\"c\" d=\"4\"><b>Card 5</b></a>");
describe('Group multiplication', function() {
checkExpr('(span.i$)*3', '<span class="i1"></span><span class="i2"></span><span class="i3"></span>');
checkExpr('p.p$*2>(i.i$+b.b$)*3', '<p class="p1"><i class="i1"></i><b class="b1"></b><i class="i2"></i><b class="b2"></b><i class="i3"></i><b class="b3"></b></p><p class="p2"><i class="i1"></i><b class="b1"></b><i class="i2"></i><b class="b2"></b><i class="i3"></i><b class="b3"></b></p>');
// checkExpr('(p.i$+ul>li.i$*2>span.s$)*3', '<p class="i1"></p><ul><li class="i1"><span class="s1"></span></li><li class="i2"><span class="s2"></span></li></ul><p class="i2"></p><ul><li class="i1"><span class="s1"></span></li><li class="i2"><span class="s2"></span></li></ul><p class="i3"></p><ul><li class="i1"><span class="s1"></span></li><li class="i2"><span class="s2"></span></li></ul>');
});
describe("text nodes", function() {
checkExpr("span>`Hello world`", "<span>Hello world</span>");
checkExpr("span>`Hello`+` world`", "<span>Hello world</span>");
checkExpr("span>`<Hello\"> & </world> '`", "<span>&lt;Hello&quot;&gt; &amp; &lt;/world&gt; &#039;</span>");
checkExpr("span>`Click `+(a[href=/url/]>`here`)+` for more info`", "<span>Click <a href=\"/url/\">here</a> for more info</span>");
checkExpr("a>`test: `+span+span", "<a>test: <span></span><span></span></a>");
checkExpr("p>i.z+`{0}`+br+`{1}`", "<p><i class=\"z\"></i>{0}<br>{1}</p>");
describe('Text nodes', function() {
checkExpr('span>{Hello world}', '<span>Hello world</span>');
// checkExpr('span{Hello world}', '<span>Hello world</span>');
checkExpr('span>{Hello}+{ world}', '<span>Hello world</span>');
// checkExpr('span>{Click }+(a[href=/url/]{here})+{ for more info}', '<span>Click <a href="/url/">here</a> for more info</span>');
// checkExpr('str{Text}', '<strong>Text</strong>');
checkExpr("a>{test: }+span+span", "<a>test: <span></span><span></span></a>"); // new
checkExpr("p>i.z+{0}+br+{1}", "<p><i class=\"z\"></i>0<br>1</p>"); // new
});

@@ -119,0 +94,0 @@

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