Skip to content

Commit

Permalink
test for browser & server, update handlebars and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusmaso committed May 23, 2016
1 parent 41936bd commit 0ef602f
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 118 deletions.
13 changes: 10 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function(grunt) {
},
dist: {
files: {
'dist/<%= pkg.name %>.js': ['lib/**/*.js']
'dist/<%= pkg.name %>.js': ['lib/index.js']
}
}
},
Expand All @@ -54,15 +54,22 @@ module.exports = function(grunt) {
reporter: 'spec',
mocha: require('mocha')
},
src: ['spec/**/*.js']
src: ['spec/index.js']
}
},
mocha_phantomjs: {
options: {
reporter: 'spec'
},
all: ['spec/index.html']
}
});

grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.registerTask('default', ['babel', 'browserify', 'uglify', 'mochaTest']);
grunt.registerTask('default', ['babel', 'browserify', 'uglify', 'mochaTest', 'mocha_phantomjs']);
};
98 changes: 51 additions & 47 deletions dist/handlebars.binding.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// handlebars.binding
// ------------------
// v0.3.4
// v0.3.5
//
// Copyright (c) 2013-2016 Mateus Maso
// Distributed under MIT license
Expand Down Expand Up @@ -713,34 +713,36 @@ var _deps2 = _interopRequireDefault(_deps);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function HandlebarsBinding(Handlebars) {
(0, _handlebars2.default)(Handlebars);
if (!_deps2.default.Handlebars) {
(0, _handlebars2.default)(Handlebars);

var extend = Handlebars.Utils.extend;
var extend = Handlebars.Utils.extend;


extend(_deps2.default, { Handlebars: Handlebars });
extend(_deps2.default, { Handlebars: Handlebars });

extend(Handlebars, {
Binding: _bindings.Binding,
IfBinding: _bindings.IfBinding,
EachBinding: _bindings.EachBinding,
bind: _core.bind,
unbind: _core.unbind,
update: _core.update
});
extend(Handlebars, {
Binding: _bindings.Binding,
IfBinding: _bindings.IfBinding,
EachBinding: _bindings.EachBinding,
bind: _core.bind,
unbind: _core.unbind,
update: _core.update
});

extend(Handlebars.Utils, {
path: _utils.path,
traverse: _utils.traverse,
removeBetween: _utils.removeBetween,
nodesBetween: _utils.nodesBetween,
removeClass: _utils.removeClass,
addClass: _utils.addClass,
hasClass: _utils.hasClass,
isFalsy: _utils.isFalsy
});
extend(Handlebars.Utils, {
path: _utils.path,
traverse: _utils.traverse,
removeBetween: _utils.removeBetween,
nodesBetween: _utils.nodesBetween,
removeClass: _utils.removeClass,
addClass: _utils.addClass,
hasClass: _utils.hasClass,
isFalsy: _utils.isFalsy
});

(0, _core.register)();
(0, _core.register)();
}

return Handlebars;
}
Expand Down Expand Up @@ -1018,30 +1020,32 @@ var _deps2 = _interopRequireDefault(_deps);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function HandlebarsElement(Handlebars) {
(0, _utils.extend)(_deps2.default, { Handlebars: Handlebars });

(0, _utils.extend)(Handlebars, {
store: _store2.default,
elements: _core.elements,
attributes: _core.attributes,
registerElement: _core.registerElement,
registerAttribute: _core.registerAttribute,
parseValue: _core.parseValue,
parseHTML: _core.parseHTML
});
if (!_deps2.default.Handlebars) {
(0, _utils.extend)(_deps2.default, { Handlebars: Handlebars });

(0, _utils.extend)(Handlebars, {
store: _store2.default,
elements: _core.elements,
attributes: _core.attributes,
registerElement: _core.registerElement,
registerAttribute: _core.registerAttribute,
parseValue: _core.parseValue,
parseHTML: _core.parseHTML
});

(0, _utils.extend)(Handlebars.Utils, {
extend: _utils.extend,
isObject: _utils.isObject,
isString: _utils.isString,
uniqueId: _utils.uniqueId,
flatten: _utils.flatten,
camelize: _utils.camelize,
replaceWith: _utils.replaceWith,
insertAfter: _utils.insertAfter,
escapeExpression: _utils.escapeExpression,
_escapeExpression: Handlebars.Utils.escapeExpression
});
(0, _utils.extend)(Handlebars.Utils, {
extend: _utils.extend,
isObject: _utils.isObject,
isString: _utils.isString,
uniqueId: _utils.uniqueId,
flatten: _utils.flatten,
camelize: _utils.camelize,
replaceWith: _utils.replaceWith,
insertAfter: _utils.insertAfter,
escapeExpression: _utils.escapeExpression,
_escapeExpression: Handlebars.Utils.escapeExpression
});
}

return Handlebars;
}
Expand Down Expand Up @@ -2927,4 +2931,4 @@ function escapeExpression(value) {
})(typeof global !== 'undefined' && global && typeof module !== 'undefined' && module ? global : this || window);

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}]},{},[1,2,3,4,5,6,7,8]);
},{}]},{},[7]);
6 changes: 3 additions & 3 deletions dist/handlebars.binding.min.js

Large diffs are not rendered by default.

58 changes: 30 additions & 28 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,36 @@ var _deps2 = _interopRequireDefault(_deps);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function HandlebarsBinding(Handlebars) {
(0, _handlebars2.default)(Handlebars);

var extend = Handlebars.Utils.extend;


extend(_deps2.default, { Handlebars: Handlebars });

extend(Handlebars, {
Binding: _bindings.Binding,
IfBinding: _bindings.IfBinding,
EachBinding: _bindings.EachBinding,
bind: _core.bind,
unbind: _core.unbind,
update: _core.update
});

extend(Handlebars.Utils, {
path: _utils.path,
traverse: _utils.traverse,
removeBetween: _utils.removeBetween,
nodesBetween: _utils.nodesBetween,
removeClass: _utils.removeClass,
addClass: _utils.addClass,
hasClass: _utils.hasClass,
isFalsy: _utils.isFalsy
});

(0, _core.register)();
if (!_deps2.default.Handlebars) {
(0, _handlebars2.default)(Handlebars);

var extend = Handlebars.Utils.extend;


extend(_deps2.default, { Handlebars: Handlebars });

extend(Handlebars, {
Binding: _bindings.Binding,
IfBinding: _bindings.IfBinding,
EachBinding: _bindings.EachBinding,
bind: _core.bind,
unbind: _core.unbind,
update: _core.update
});

extend(Handlebars.Utils, {
path: _utils.path,
traverse: _utils.traverse,
removeBetween: _utils.removeBetween,
nodesBetween: _utils.nodesBetween,
removeClass: _utils.removeClass,
addClass: _utils.addClass,
hasClass: _utils.hasClass,
isFalsy: _utils.isFalsy
});

(0, _core.register)();
}

return Handlebars;
}
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "handlebars.binding",
"description": "Handlebars plugin for using one-way data binding",
"version": "0.3.4",
"version": "0.3.5",
"author": "mateusmaso",
"license": "MIT",
"keywords": [
Expand All @@ -16,21 +16,22 @@
"grunt-browserify": "~4.0.1",
"grunt-contrib-uglify": "~0.5.0",
"grunt-mocha-test": "~0.11.0",
"grunt-mocha-phantomjs": "~3.0.0",
"babel-preset-es2015": "^6.5.0",
"babelify": "^7.2.0",
"jsdom": "^9.1.0",
"handlebars": "~1.1.0"
"handlebars": "~4.0.5"
},
"repository": {
"type": "git",
"url": "http://github.com/mateusmaso/handlebars.binding"
},
"dependencies": {
"handlebars.element": "~0.3.2",
"handlebars.element": "~0.3.3",
"observe-js": "~0.5.7"
},
"scripts": {
"test": "grunt mochaTest"
"test": "grunt mochaTest mocha_phantomjs"
},
"engines": {
"node" : "~5.9.0"
Expand Down
21 changes: 21 additions & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>handlebars.binding</title>
<link rel="stylesheet" media="all" href="../node_modules/mocha/mocha.css">
<script src="../node_modules/mocha/mocha.js"></script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/handlebars/dist/handlebars.js"></script>
<script src="../dist/handlebars.binding.js"></script>
</head>

<body>
<div id="mocha"></div>
<div id="fixtures"></div>

<script>mocha.setup('bdd');</script>
<script src="index.js"></script>
<script>mocha.run();</script>
</body>
</html>
14 changes: 8 additions & 6 deletions spec/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var jsdom = require("jsdom").jsdom;
var document = global.document = jsdom("test");
var window = global.window = document.defaultView;
var chai = require("chai");
var Handlebars = require("handlebars");
require("../lib").default(Handlebars);
if (typeof window === "undefined") {
var jsdom = require("jsdom").jsdom;
var document = global.document = jsdom("test");
var window = global.window = document.defaultView;
var chai = require("chai");
var Handlebars = require("handlebars");
require("../lib").default(Handlebars);
}

describe("handlebars.binding", function() {
describe("bind helper", function() {
Expand Down
56 changes: 29 additions & 27 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,35 @@ import {
import deps from "./deps";

export default function HandlebarsBinding(Handlebars) {
HandlebarsElement(Handlebars);

var {extend} = Handlebars.Utils;

extend(deps, {Handlebars});

extend(Handlebars, {
Binding,
IfBinding,
EachBinding,
bind,
unbind,
update
});

extend(Handlebars.Utils, {
path,
traverse,
removeBetween,
nodesBetween,
removeClass,
addClass,
hasClass,
isFalsy
});

register();
if (!deps.Handlebars) {
HandlebarsElement(Handlebars);

var {extend} = Handlebars.Utils;

extend(deps, {Handlebars});

extend(Handlebars, {
Binding,
IfBinding,
EachBinding,
bind,
unbind,
update
});

extend(Handlebars.Utils, {
path,
traverse,
removeBetween,
nodesBetween,
removeClass,
addClass,
hasClass,
isFalsy
});

register();
}

return Handlebars;
}
Expand Down

0 comments on commit 0ef602f

Please sign in to comment.