mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
appease IE on CSS styles
This commit is contained in:
parent
e3e9ac8675
commit
17d2ced9cc
5 changed files with 18 additions and 15 deletions
|
|
@ -254,11 +254,11 @@ angularDirective("ng:hide", function(expression, element){
|
|||
|
||||
angularDirective("ng:style", function(expression, element){
|
||||
return function(element){
|
||||
var resetStyle = element.css();
|
||||
var resetStyle = getStyle(element);
|
||||
this.$onEval(function(){
|
||||
var style = this.$eval(expression) || {}, key, mergedStyle = {};
|
||||
for(key in style) {
|
||||
if (typeof resetStyle[key] == 'undefined') resetStyle[key] = null;
|
||||
if (resetStyle[key] === undefined) resetStyle[key] = '';
|
||||
mergedStyle[key] = style[key];
|
||||
}
|
||||
for(key in resetStyle) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@ function jqClearData(element) {
|
|||
}
|
||||
}
|
||||
|
||||
function getStyle(element) {
|
||||
var current = {}, style = element[0].style, value;
|
||||
for (var name in style) {
|
||||
value = style[name];
|
||||
if (1*name != name && name != 'cssText' && value && typeof value == 'string' && value !='false')
|
||||
current[name] = value;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
function JQLite(element) {
|
||||
if (isElement(element)) {
|
||||
this[0] = element;
|
||||
|
|
@ -175,15 +185,8 @@ JQLite.prototype = {
|
|||
} else {
|
||||
return style[name];
|
||||
}
|
||||
} else if(name) {
|
||||
extend(style, name);
|
||||
} else {
|
||||
var current = {};
|
||||
for (var i=0; i<style.length; i++) {
|
||||
name = style[i];
|
||||
current[name] = style[name];
|
||||
}
|
||||
return current;
|
||||
extend(style, name);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
2
test.sh
2
test.sh
|
|
@ -4,4 +4,4 @@ if [[ $tests = "" ]]; then
|
|||
fi
|
||||
|
||||
java -jar lib/jstestdriver/JsTestDriver.jar --tests "$tests"
|
||||
# java -jar lib/jstestdriver/JsTestDriver.jar --tests "$tests" --config jsTestDriver-jquery.conf
|
||||
#java -jar lib/jstestdriver/JsTestDriver.jar --tests "$tests" --config jsTestDriver-jquery.conf
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){
|
|||
state.scope.$eval();
|
||||
assertEquals('abc', state.scope.model.price);
|
||||
};
|
||||
|
||||
|
||||
BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
|
||||
var c = this.compile('<textarea name="model.note">abc</textarea>');
|
||||
c.scope.$eval();
|
||||
|
|
|
|||
|
|
@ -184,13 +184,13 @@ describe("directives", function(){
|
|||
it('should preserve and remove previus style', function(){
|
||||
var scope = compile('<div style="color:red;" ng:style="myStyle"></div>');
|
||||
scope.$eval();
|
||||
expect(element.css()).toEqual({color:'red'});
|
||||
expect(getStyle(element)).toEqual({color:'red'});
|
||||
scope.myStyle = {color:'blue', width:'10px'};
|
||||
scope.$eval();
|
||||
expect(element.css()).toEqual({color:'blue', width:'10px'});
|
||||
expect(getStyle(element)).toEqual({color:'blue', width:'10px'});
|
||||
scope.myStyle = {};
|
||||
scope.$eval();
|
||||
expect(element.css()).toEqual({color:'red'});
|
||||
expect(getStyle(element)).toEqual({color:'red'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue