Skip to content

Commit

Permalink
fix #54
Browse files Browse the repository at this point in the history
  • Loading branch information
leeluolee committed Nov 20, 2015
1 parent 8a5ab18 commit 68f029a
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ example
npm-debug.log
*/tmp/*
test/tmp/*
test/runner/dom.bundle.js
test/coverage/*
coverage*
out/*
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regularjs",
"version": "0.4.1",
"version": "0.4.2",
"main": "dist/regular.js",
"description": "reactjs + angularjs = regularjs",
"authors": "@leeluolee <[email protected]>",
Expand Down
51 changes: 29 additions & 22 deletions dist/regular.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@author leeluolee
@version 0.4.1
@version 0.4.2
@homepage http://regularjs.github.io
*/
(function webpackUniversalModuleDefinition(root, factory) {
Expand Down Expand Up @@ -1082,9 +1082,10 @@ return /******/ (function(modules) { // webpackBootstrap
})();

// 3ks for angular's raf service
var k
dom.nextReflow = dom.msie? function(callback){
return dom.nextFrame(function(){
var k = document.body.offsetWidth;
k = document.body.offsetWidth;
callback();
})
}: dom.nextFrame;
Expand Down Expand Up @@ -1471,7 +1472,9 @@ return /******/ (function(modules) { // webpackBootstrap
return function fire(){
var args = slice.call(arguments)
args.unshift(value);
self.$emit.apply(self, args);
self.$update(function(){
self.$emit.apply(self, args);
})
}
}
}
Expand Down Expand Up @@ -1584,28 +1587,32 @@ return /******/ (function(modules) { // webpackBootstrap
// Example: <div r-hide={{items.length > 0}}></div>
'r-hide': function(elem, value){
var preBool = null, compelete;
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
if( _.isExpr(value) || typeof value === "string"){
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
elem.style.display = "none"
compelete = null;
})
}else{
elem.style.display = "none"
compelete = null;
})
}

}else{
elem.style.display = "none"
}

}else{
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
}
}
}
});
});
}else if(!!value){
elem.style.display = "none";
}
},
'r-html': function(elem, value){
this.$watch(value, function(nvalue){
Expand Down
4 changes: 2 additions & 2 deletions dist/regular.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regularjs",
"version": "0.4.1",
"version": "0.4.2",
"author": {
"name": "leeluolee"
},
Expand Down
42 changes: 23 additions & 19 deletions src/directive/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,32 @@ module.exports = {
// Example: <div r-hide={{items.length > 0}}></div>
'r-hide': function(elem, value){
var preBool = null, compelete;
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
if( _.isExpr(value) || typeof value === "string"){
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
elem.style.display = "none"
compelete = null;
})
}else{
elem.style.display = "none"
compelete = null;
})
}

}else{
elem.style.display = "none"
}

}else{
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
}
}
}
});
});
}else if(!!value){
elem.style.display = "none";
}
},
'r-html': function(elem, value){
this.$watch(value, function(nvalue){
Expand Down
3 changes: 2 additions & 1 deletion src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,10 @@ dom.nextFrame = (function(){
})();

// 3ks for angular's raf service
var k
dom.nextReflow = dom.msie? function(callback){
return dom.nextFrame(function(){
var k = document.body.offsetWidth;
k = document.body.offsetWidth;
callback();
})
}: dom.nextFrame;
Expand Down
4 changes: 3 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ _.handleEvent = function(value, type ){
return function fire(){
var args = slice.call(arguments)
args.unshift(value);
self.$emit.apply(self, args);
self.$update(function(){
self.$emit.apply(self, args);
})
}
}
}
Expand Down
60 changes: 38 additions & 22 deletions test/runner/dom.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@

})

describe("Milestones v0.4.1", function(){
describe("Milestones v0.4.*", function(){
it("#53 nested component with delegate-event and [postion:after or before ] bug", function( done ){
var after = document.createElement('div');
after.setAttribute('id',1)
Expand Down Expand Up @@ -753,6 +753,15 @@


})

it("r-hide={true} should not throwException", function(){

expect(function(){
var component = new Regular({
template: "<div r-hide={true} ></div>"
})
}).to.not.throwException();
})
})

it('bugfix #50', function(){
Expand Down Expand Up @@ -6163,9 +6172,10 @@
})();

// 3ks for angular's raf service
var k
dom.nextReflow = dom.msie? function(callback){
return dom.nextFrame(function(){
var k = document.body.offsetWidth;
k = document.body.offsetWidth;
callback();
})
}: dom.nextFrame;
Expand Down Expand Up @@ -6552,7 +6562,9 @@
return function fire(){
var args = slice.call(arguments)
args.unshift(value);
self.$emit.apply(self, args);
self.$update(function(){
self.$emit.apply(self, args);
})
}
}
}
Expand Down Expand Up @@ -9632,28 +9644,32 @@
// Example: <div r-hide={{items.length > 0}}></div>
'r-hide': function(elem, value){
var preBool = null, compelete;
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
if( _.isExpr(value) || typeof value === "string"){
this.$watch(value, function(nvalue){
var bool = !!nvalue;
if(bool === preBool) return;
preBool = bool;
if(bool){
if(elem.onleave){
compelete = elem.onleave(function(){
elem.style.display = "none"
compelete = null;
})
}else{
elem.style.display = "none"
compelete = null;
})
}

}else{
elem.style.display = "none"
}

}else{
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
if(compelete) compelete();
elem.style.display = "";
if(elem.onenter){
elem.onenter();
}
}
}
});
});
}else if(!!value){
elem.style.display = "none";
}
},
'r-html': function(elem, value){
this.$watch(value, function(nvalue){
Expand Down
11 changes: 10 additions & 1 deletion test/spec/browser-bugfix.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ var template = '<input type="text" class="form-control" \

})

describe("Milestones v0.4.1", function(){
describe("Milestones v0.4.*", function(){
it("#53 nested component with delegate-event and [postion:after or before ] bug", function( done ){
var after = document.createElement('div');
after.setAttribute('id',1)
Expand Down Expand Up @@ -500,6 +500,15 @@ describe("Milestones v0.4.1", function(){


})

it("r-hide={true} should not throwException", function(){

expect(function(){
var component = new Regular({
template: "<div r-hide={true} ></div>"
})
}).to.not.throwException();
})
})

it('bugfix #50', function(){
Expand Down

0 comments on commit 68f029a

Please sign in to comment.