main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
855 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | function hasImportant (rawDecl) {
|
---|
4 | var parts = rawDecl.split(' ');
|
---|
5 |
|
---|
6 | for (var i = 0; i < parts.length; i++) {
|
---|
7 | var part = parts[i].trim();
|
---|
8 |
|
---|
9 | if (part === '!important') return true;
|
---|
10 | }
|
---|
11 |
|
---|
12 | return false;
|
---|
13 | }
|
---|
14 |
|
---|
15 | exports.addon = function (renderer) {
|
---|
16 | var decl = renderer.decl;
|
---|
17 |
|
---|
18 | renderer.decl = function (prop, value) {
|
---|
19 | var rawDecl = decl(prop, value);
|
---|
20 | var decls = rawDecl.split(';');
|
---|
21 | var css = '';
|
---|
22 |
|
---|
23 | for (var i = 0; i < decls.length; i++) {
|
---|
24 | rawDecl = decls[i].trim();
|
---|
25 |
|
---|
26 | if (!rawDecl) continue;
|
---|
27 |
|
---|
28 | // Don't add "!important" if it is already added.
|
---|
29 | if (!hasImportant(rawDecl)) {
|
---|
30 | css += rawDecl + ' !important;';
|
---|
31 | } else {
|
---|
32 | css += rawDecl + ';';
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | return css;
|
---|
37 | };
|
---|
38 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.