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

htmlbars

Package Overview
Dependencies
Maintainers
2
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlbars - npm Package Compare versions

Comparing version 0.1.11 to 0.1.12

dist/cjs/htmlbars-compiler-tests/htmlbars-compiler/walker.jshint.js

12

dist/cjs/htmlbars-compiler-tests/combined_ast_node-test.js

@@ -146,3 +146,3 @@ "use strict";

element("img", [
attr("id", text(""))
attr("id", text(""), true)
])

@@ -234,3 +234,3 @@ ]));

text("some "),
element("div", [ attr("class", sexpr([id('foo')])) ], [], [
element("div", [ attr("class", [ sexpr([id('foo')]) ], false) ], [], [
text("content")

@@ -334,3 +334,3 @@ ]),

astEqual(t, root([
element('p', [attr('class', text('bar'))], [mustache([id('action'), string('boom')])], [
element('p', [ attr('class', text('bar'), true) ], [mustache([id('action'), string('boom')])], [
text('Some content')

@@ -463,5 +463,5 @@ ])

component('x-foo', [
attr('a', text('b')),
attr('c', text('d')),
attr('e', sexpr([id('f')])),
attr('a', text('b'), false),
attr('c', text('d'), true),
attr('e', [ sexpr([id('f')]) ], false),
attr('id', [ sexpr([id('bar')]) ], true),

@@ -468,0 +468,0 @@ attr('class', [ string('foo-'), sexpr([id('bar')]) ], true)

@@ -121,2 +121,3 @@ "use strict";

test("Null unquoted attribute value removes that attribute", function() {
var template = compile('<input disabled={{isDisabled}}>');

@@ -128,2 +129,18 @@ var fragment = template({isDisabled: null}, env);

test("unquoted attribute string is just that", function() {
var template = compile('<input value=funstuff>');
var fragment = template({}, env);
equalTokens(fragment, '<input value="funstuff">');
});
test("unquoted attribute expression is string", function() {
var template = compile('<input value={{funstuff}}>');
var fragment = template({funstuff: "oh my"}, env);
equalTokens(fragment, '<input value="oh my">');
});
test("Simple elements can have arbitrary attributes", function() {

@@ -148,9 +165,2 @@ var template = compile("<div data-some-data='foo'>content</div>");

test("checked attribute and checked property are present after clone and hydrate", function() {
var template = compile("<input checked=\"checked\">");
var fragment = template({}, env);
ok(fragment.checked, 'input is checked');
equalTokens(fragment, "<input checked='checked'>");
});
function shouldBeVoid(tagName) {

@@ -157,0 +167,0 @@ var html = "<" + tagName + " data-foo='bar'><p>hello</p>";

"use strict";
var compile = require("./htmlbars-compiler/compiler").compile;
var compilerSpec = require("./htmlbars-compiler/compiler").compilerSpec;
exports.compilerSpec = compilerSpec;
var Walker = require("./htmlbars-compiler/walker")["default"];
exports.compile = compile;
exports.compilerSpec = compilerSpec;
exports.Walker = Walker;

@@ -145,4 +145,3 @@ "use strict";

var quoted = attr.quoted;
var params = quoted ? attr.value : [ attr.value ];
var params = attr.value;

@@ -156,3 +155,3 @@ this.opcode('program', null, null);

}
this.opcode('attribute', quoted, attr.name, params.length, this.elementNum);
this.opcode('attribute', attr.quoted, attr.name, params.length, this.elementNum);
};

@@ -159,0 +158,0 @@

@@ -86,10 +86,13 @@ "use strict";

this.tokenizer.state = 'attributeValueUnquoted';
token.markAttributeQuoted(false);
token.addToAttributeValue(mustache.sexpr);
token.finalizeAttributeValue();
return;
case "attributeValueDoubleQuoted":
case "attributeValueSingleQuoted":
token.markAttributeQuoted(true);
token.addToAttributeValue(mustache.sexpr);
token.attributes[token.attributes.length - 1].quoted = true;
return;
case "attributeValueUnquoted":
token.markAttributeQuoted(false);
token.addToAttributeValue(mustache.sexpr);

@@ -96,0 +99,0 @@ return;

@@ -10,7 +10,10 @@ "use strict";

StartTag.prototype.startAttribute = function(char) {
this.finalizeAttributeValue();
this.currentAttribute = new AttrNode(char.toLowerCase(), []);
this.currentAttribute = new AttrNode(char.toLowerCase(), [], null);
this.attributes.push(this.currentAttribute);
};
StartTag.prototype.markAttributeQuoted = function(value) {
this.currentAttribute.quoted = value;
};
StartTag.prototype.addToAttributeName = function(char) {

@@ -35,3 +38,2 @@ this.currentAttribute.name += char;

StartTag.prototype.finalize = function() {
this.finalizeAttributeValue();
delete this.currentAttribute;

@@ -50,12 +52,11 @@ return this;

if (attr.value.length === 0) {
attr.value = new TextNode("");
} else if (attr.value.length === 1) {
part = attr.value[0];
if (part.type === 'sexpr') {
if (!attr.quoted) {
attr.value = part;
}
if (attr.quoted) {
attr.value = new TextNode("");
} else {
attr.value = part;
attr.value = null;
}
} else if (attr.value.length === 1) {
if (attr.value[0].type === 'text') {
attr.value = attr.value[0];
}
} else {

@@ -62,0 +63,0 @@ // Convert TextNode to StringNode

@@ -11,2 +11,8 @@ "use strict";

if (options && options.plugins && options.plugins.ast) {
for (var i = 0, l = options.plugins.ast.length; i < l; i++) {
combined = options.plugins.ast[i](combined);
}
}
return combined;

@@ -13,0 +19,0 @@ }

@@ -7,3 +7,3 @@ "use strict";

* See https://raw.githubusercontent.com/tildeio/htmlbars/master/LICENSE
* @version 0.1.11
* @version 0.1.12
*/

@@ -13,2 +13,3 @@

var compileSpec = require("./htmlbars-compiler/compiler").compileSpec;
var Walker = require("./htmlbars-compiler/walker")["default"];
var Morph = require("./morph/morph")["default"];

@@ -20,2 +21,3 @@ var DOMHelper = require("./morph/dom-helper")["default"];

exports.Morph = Morph;
exports.DOMHelper = DOMHelper;
exports.DOMHelper = DOMHelper;
exports.Walker = Walker;

@@ -82,2 +82,10 @@ "use strict";

markAttributeQuoted: function(value) {
this.token.markAttributeQuoted(value);
},
finalizeAttributeValue: function() {
this.token.finalizeAttributeValue();
},
addToAttributeValue: function(char) {

@@ -312,4 +320,6 @@ this.token.addToAttributeValue(char);

this.state = 'attributeValueDoubleQuoted';
this.markAttributeQuoted(true);
} else if (char === "'") {
this.state = 'attributeValueSingleQuoted';
this.markAttributeQuoted(true);
} else if (char === ">") {

@@ -319,2 +329,3 @@ return this.emitToken();

this.state = 'attributeValueUnquoted';
this.markAttributeQuoted(false);
this.addToAttributeValue(char);

@@ -326,2 +337,3 @@ }

if (char === '"') {
this.finalizeAttributeValue();
this.state = 'afterAttributeValueQuoted';

@@ -337,2 +349,3 @@ } else if (char === "&") {

if (char === "'") {
this.finalizeAttributeValue();
this.state = 'afterAttributeValueQuoted';

@@ -348,2 +361,3 @@ } else if (char === "&") {

if (isSpace(char)) {
this.finalizeAttributeValue();
this.state = 'beforeAttributeName';

@@ -404,3 +418,3 @@ } else if (char === "&") {

startAttribute: function(char) {
this.currentAttribute = [char.toLowerCase(), null];
this.currentAttribute = [char.toLowerCase(), null, null];
this.attributes.push(this.currentAttribute);

@@ -413,2 +427,6 @@ },

markAttributeQuoted: function(value) {
this.currentAttribute[2] = value;
},
addToAttributeValue: function(char) {

@@ -419,2 +437,9 @@ this.currentAttribute[1] = this.currentAttribute[1] || "";

finalizeAttributeValue: function() {
// Set the value of quoted attributes to a blank string
if (this.currentAttribute[2] && this.currentAttribute[1] === null) {
this.currentAttribute[1] = '';
}
},
finalize: function() {

@@ -421,0 +446,0 @@ delete this.currentAttribute;

@@ -1,2 +0,11 @@

import {compilerSpec} from "./htmlbars-compiler/compiler";
export {compilerSpec};
import {
compile,
compilerSpec
} from "./htmlbars-compiler/compiler";
import Walker from "./htmlbars-compiler/walker";
export {
compile,
compilerSpec,
Walker
};

@@ -144,4 +144,3 @@ import TemplateVisitor from "./template_visitor";

var quoted = attr.quoted;
var params = quoted ? attr.value : [ attr.value ];
var params = attr.value;

@@ -155,3 +154,3 @@ this.opcode('program', null, null);

}
this.opcode('attribute', quoted, attr.name, params.length, this.elementNum);
this.opcode('attribute', attr.quoted, attr.name, params.length, this.elementNum);
};

@@ -158,0 +157,0 @@

@@ -87,10 +87,13 @@ import {

this.tokenizer.state = 'attributeValueUnquoted';
token.markAttributeQuoted(false);
token.addToAttributeValue(mustache.sexpr);
token.finalizeAttributeValue();
return;
case "attributeValueDoubleQuoted":
case "attributeValueSingleQuoted":
token.markAttributeQuoted(true);
token.addToAttributeValue(mustache.sexpr);
token.attributes[token.attributes.length - 1].quoted = true;
return;
case "attributeValueUnquoted":
token.markAttributeQuoted(false);
token.addToAttributeValue(mustache.sexpr);

@@ -97,0 +100,0 @@ return;

@@ -5,7 +5,10 @@ import { Chars, StartTag, EndTag } from "../../simple-html-tokenizer";

StartTag.prototype.startAttribute = function(char) {
this.finalizeAttributeValue();
this.currentAttribute = new AttrNode(char.toLowerCase(), []);
this.currentAttribute = new AttrNode(char.toLowerCase(), [], null);
this.attributes.push(this.currentAttribute);
};
StartTag.prototype.markAttributeQuoted = function(value) {
this.currentAttribute.quoted = value;
};
StartTag.prototype.addToAttributeName = function(char) {

@@ -30,3 +33,2 @@ this.currentAttribute.name += char;

StartTag.prototype.finalize = function() {
this.finalizeAttributeValue();
delete this.currentAttribute;

@@ -45,12 +47,11 @@ return this;

if (attr.value.length === 0) {
attr.value = new TextNode("");
} else if (attr.value.length === 1) {
part = attr.value[0];
if (part.type === 'sexpr') {
if (!attr.quoted) {
attr.value = part;
}
if (attr.quoted) {
attr.value = new TextNode("");
} else {
attr.value = part;
attr.value = null;
}
} else if (attr.value.length === 1) {
if (attr.value[0].type === 'text') {
attr.value = attr.value[0];
}
} else {

@@ -57,0 +58,0 @@ // Convert TextNode to StringNode

@@ -10,2 +10,8 @@ import { parse } from "./handlebars/compiler/base";

if (options && options.plugins && options.plugins.ast) {
for (var i = 0, l = options.plugins.ast.length; i < l; i++) {
combined = options.plugins.ast[i](combined);
}
}
return combined;

@@ -12,0 +18,0 @@ }

@@ -6,9 +6,13 @@ /*

* See https://raw.githubusercontent.com/tildeio/htmlbars/master/LICENSE
* @version 0.1.11
* @version 0.1.12
*/
import {compile, compileSpec} from "./htmlbars-compiler/compiler";
import {
compile,
compileSpec
} from "./htmlbars-compiler/compiler";
import Walker from "./htmlbars-compiler/walker";
import Morph from "./morph/morph";
import DOMHelper from "./morph/dom-helper";
export {compile, compileSpec, Morph, DOMHelper};
export {compile, compileSpec, Morph, DOMHelper, Walker};

@@ -78,2 +78,10 @@ /*jshint boss:true*/

markAttributeQuoted: function(value) {
this.token.markAttributeQuoted(value);
},
finalizeAttributeValue: function() {
this.token.finalizeAttributeValue();
},
addToAttributeValue: function(char) {

@@ -308,4 +316,6 @@ this.token.addToAttributeValue(char);

this.state = 'attributeValueDoubleQuoted';
this.markAttributeQuoted(true);
} else if (char === "'") {
this.state = 'attributeValueSingleQuoted';
this.markAttributeQuoted(true);
} else if (char === ">") {

@@ -315,2 +325,3 @@ return this.emitToken();

this.state = 'attributeValueUnquoted';
this.markAttributeQuoted(false);
this.addToAttributeValue(char);

@@ -322,2 +333,3 @@ }

if (char === '"') {
this.finalizeAttributeValue();
this.state = 'afterAttributeValueQuoted';

@@ -333,2 +345,3 @@ } else if (char === "&") {

if (char === "'") {
this.finalizeAttributeValue();
this.state = 'afterAttributeValueQuoted';

@@ -344,2 +357,3 @@ } else if (char === "&") {

if (isSpace(char)) {
this.finalizeAttributeValue();
this.state = 'beforeAttributeName';

@@ -400,3 +414,3 @@ } else if (char === "&") {

startAttribute: function(char) {
this.currentAttribute = [char.toLowerCase(), null];
this.currentAttribute = [char.toLowerCase(), null, null];
this.attributes.push(this.currentAttribute);

@@ -409,2 +423,6 @@ },

markAttributeQuoted: function(value) {
this.currentAttribute[2] = value;
},
addToAttributeValue: function(char) {

@@ -415,2 +433,9 @@ this.currentAttribute[1] = this.currentAttribute[1] || "";

finalizeAttributeValue: function() {
// Set the value of quoted attributes to a blank string
if (this.currentAttribute[2] && this.currentAttribute[1] === null) {
this.currentAttribute[1] = '';
}
},
finalize: function() {

@@ -417,0 +442,0 @@ delete this.currentAttribute;

@@ -163,2 +163,11 @@ define("htmlbars-tests/htmlbars-compiler.jshint",

});
define("htmlbars-tests/htmlbars-compiler/walker.jshint",
[],
function() {
"use strict";
module('JSHint - htmlbars-tests/htmlbars-compiler');
test('htmlbars-tests/htmlbars-compiler/walker.js should pass jshint', function() {
ok(true, 'htmlbars-tests/htmlbars-compiler/walker.js should pass jshint.');
});
});
define("htmlbars-tests/htmlbars-runtime.jshint",

@@ -165,0 +174,0 @@ [],

var packagesConfig = {
"version": "0.1.11",
"revision": "09230391c8222d1d75fcff84b704a24fed70c17d",
"version": "0.1.12",
"revision": "9a332df762e9fe38bf7fbbbc544974e90e2a3b12",
"vendored": {},

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

{
"name": "htmlbars",
"version": "0.1.11",
"version": "0.1.12",
"description": "HTMLBars compiles Handlebars templates into document fragments rather than string buffers",

@@ -42,2 +42,3 @@ "main": "dist/cjs/htmlbars.js",

"copy-dereference": "~1.0.0",
"ember-cli": "^0.1.2",
"git-repo-version": "0.0.2",

@@ -44,0 +45,0 @@ "handlebars": "mmun/handlebars.js#5df374595157d6ca13de9e8ada6a5bb064e9b1ae",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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