mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 11:37:38 +08:00
refactor(jqLite): remove jqLite show/hide support
it turns out that even with our tricks, jqLite#show is not usable in practice and definitely not on par with jQuery. so rather than introducing half-baked apis which introduce issues, I'm removing them. I also removed show/hide uses from docs, since they are not needed. Breaks jqLite.hide/jqLite.show which are no longer available.
This commit is contained in:
@@ -63,7 +63,6 @@ var _undefined = undefined,
|
||||
$boolean = 'boolean',
|
||||
$console = 'console',
|
||||
$date = 'date',
|
||||
$display = 'display',
|
||||
$length = 'length',
|
||||
$name = 'name',
|
||||
$noop = 'noop',
|
||||
|
||||
@@ -710,7 +710,7 @@ angularDirective("ng:class-even", ngClass(function(i){return i % 2 === 1;}));
|
||||
angularDirective("ng:show", function(expression, element){
|
||||
return function(element){
|
||||
this.$watch(expression, function(scope, value){
|
||||
toBoolean(value) ? element.show() : element.hide();
|
||||
element.css('display', toBoolean(value) ? '' : 'none');
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -751,7 +751,7 @@ angularDirective("ng:show", function(expression, element){
|
||||
angularDirective("ng:hide", function(expression, element){
|
||||
return function(element){
|
||||
this.$watch(expression, function(scope, value){
|
||||
toBoolean(value) ? element.hide() : element.show();
|
||||
element.css('display', toBoolean(value) ? 'none' : '');
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
* - [text()](http://api.jquery.com/text/)
|
||||
* - [trigger()](http://api.jquery.com/trigger/)
|
||||
* - [eq()](http://api.jquery.com/eq/)
|
||||
* - [show()](http://api.jquery.com/show/)
|
||||
* - [hide()](http://api.jquery.com/hide/)
|
||||
*
|
||||
* ## Additionally these methods extend the jQuery and are available in both jQuery and jQuery lite
|
||||
* version:
|
||||
@@ -456,32 +454,6 @@ forEach({
|
||||
return element.getElementsByTagName(selector);
|
||||
},
|
||||
|
||||
hide: function(element) {
|
||||
if (element.style) {
|
||||
if(element.style.display !=="none" && !JQLiteData(element,"olddisplay")) {
|
||||
JQLiteData( element, "olddisplay", element.style.display);
|
||||
}
|
||||
element.style.display = "none";
|
||||
}
|
||||
},
|
||||
|
||||
show: function(element) {
|
||||
if(element.style) {
|
||||
var display = element.style.display;
|
||||
if ( display === "" || display === "none" ) {
|
||||
|
||||
// restore the original value overwritten by hide if present or default to nothing (which
|
||||
// will let browser correctly choose between 'inline' or 'block')
|
||||
element.style.display = JQLiteData(element, "olddisplay") || "";
|
||||
|
||||
// if the previous didn't make the element visible then there are some cascading rules that
|
||||
// are still hiding it, so let's default to 'block', which might be incorrect in case of
|
||||
// elmenents that should be 'inline' by default, but oh well :-)
|
||||
if (!isVisible([element])) element.style.display = "block";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
clone: JQLiteClone
|
||||
}, function(fn, name){
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user