Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

README.md 1.5 KiB

3 lat temu
123456789101112131415161718192021222324252627
  1. CSSStyleDeclaration
  2. ===================
  3. CSSStyleDeclaration is a work-a-like to the CSSStyleDeclaration class in Nikita Vasilyev's [CSSOM](https://github.com/NV/CSSOM). I made it so that when using [jQuery in node](https://github.com/tmtk75/node-jquery) setting css attributes via $.fn.css() would work. node-jquery uses [jsdom](https://github.com/tmpvar/jsdom) to create a DOM to use in node. jsdom uses CSSOM for styling, and CSSOM's implementation of the [CSSStyleDeclaration](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration) doesn't support [CSS2Properties](http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties), which is how jQuery's [$.fn.css()](http://api.jquery.com/css/) operates.
  4. Why not just issue a pull request?
  5. ----
  6. Well, NV wants to keep CSSOM fast (which I can appreciate) and CSS2Properties aren't required by the standard (though every browser has the interface). So I figured the path of least resistence would be to just modify this one class, publish it as a node module (that requires CSSOM) and then make a pull request of jsdom to use it.
  7. How do I test this code?
  8. ---
  9. `npm test` should do the trick, assuming you have the dev dependencies installed:
  10. > ```
  11. > $ npm test
  12. >
  13. > tests
  14. > ✔ Verify Has Properties
  15. > ✔ Verify Has Functions
  16. > ✔ Verify Has Special Properties
  17. > ✔ Test From Style String
  18. > ✔ Test From Properties
  19. > ✔ Test Shorthand Properties
  20. > ✔ Test width and height Properties and null and empty strings
  21. > ✔ Test Implicit Properties
  22. > ```