fix diff of css rule removal
This commit is contained in:
parent
dc9cae09fc
commit
63a7461657
6 changed files with 41 additions and 6 deletions
|
|
@ -1,5 +1,13 @@
|
|||
## Change Log
|
||||
|
||||
[v0.1.13](/mithril/archive/v0.1.13) - maintenance
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
- Removing CSS rules now diffs correctly [#79](https://github.com/lhorie/mithril.js/issues/79)
|
||||
|
||||
---
|
||||
|
||||
[v0.1.12](/mithril/archive/v0.1.12) - maintenance
|
||||
|
||||
### News:
|
||||
|
|
@ -14,7 +22,6 @@
|
|||
|
||||
---
|
||||
|
||||
|
||||
[v0.1.11](/mithril/archive/v0.1.11) - maintenance
|
||||
|
||||
### News:
|
||||
|
|
|
|||
|
|
@ -138,12 +138,23 @@ m("div", {style: {border: "1px solid red"}}); //yields <div style="border:1px so
|
|||
|
||||
Note that in order to keep the framework lean, Mithril does not auto-append units like `px` or `%` to any values. Typically, you should not even be using inline styles to begin with (unless you are dynamically changing them).
|
||||
|
||||
Mithril also does not auto-camel-case CSS properties on inline style attributes, so you should use the Javascript syntax when setting them:
|
||||
Mithril also does not auto-camel-case CSS properties on inline style attributes, so you should use the Javascript syntax when setting them via Javascript objects:
|
||||
|
||||
```javascript
|
||||
m("div", {style: {textAlign: "center"}}); //yields <div style="text-align:1px solid red;"></div>
|
||||
m("div", {style: {textAlign: "center"}}); //yields <div style="text-align:center;"></div>
|
||||
|
||||
//this does not work
|
||||
m("div", {style: {"text-align": "center"}});
|
||||
```
|
||||
|
||||
You can, however, use CSS syntax when defining style rules as inline strings:
|
||||
|
||||
```javascript
|
||||
m("div[style='text-align:center']"); //yields <div style="text-align:center;"></div>
|
||||
```
|
||||
|
||||
One caveat of using the CSS syntax is that it clobbers the `style` attribute in the DOM element on redraws, so this syntax is not appropriate if you need to use it in conjunction with 3rd party tools that modify the element's style outside of Mithril's templates (e.g. via `config`, which is explained below)
|
||||
|
||||
---
|
||||
|
||||
You can define a non-HTML-standard attribute called `config`. This special parameter allows you to call methods on the DOM element after it gets created.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue