[Discuss] Reset class style for element
There are problems about reset class styles. This is the exmaple(or like this issue #218 ):
<template>
<div>
<text class="{{className}}" onclick="toggle">Hello Weex</text>
</div>
</template>
<style>
.normal {
font-size: 40px;
}
.hightlight {
font-size: 40px;
color: red;
}
</style>
<script>
module.exports = {
data: {
className: 'highlight'
},
methods: {
toggle: function() {
if (this.className === 'normal') {
this.className = 'hightlight'
} else {
this.className = 'normal'
}
}
}
}
</script>
When click the text, the color of the text is still red. Because we have no way to clear the last class style.
So maybe we can give the style a empty value(string) to clear the style through calling 'updateStyles'.
What's your opinion?
This could work on h5-render after changing some valueFilter stuff.
Removing style should mean "backing to the default style", but an empty string is meaningful for some styles , especially for extending components, it's difficult for them to understand. Anyway, now passing an empty string to remove style is working for most of styles.
In CSS spec, a empty string will reset the style. Maybe it's the common way to do this.
@Hanks10100 Please have a look at this issue. Thanks.
After fixed this bug in #953 , jsfm will set empty string on the style which need to be reset. I'm sure it works well on HTML5. I hope this feature could be fully support by native.
Though the code merged into jsfm branch, maybe more discussion needed with the native part about the detail of sending default value. @Hanks10100 @cxfeng1 @zshshr
Thanks.