1 | 'use strict';
|
2 |
|
3 | var cssSelector = require('./styleSelector'),
|
4 | parseCSS = require('css-rules'),
|
5 | styleSelector = cssSelector('<style attribute>', [ 1, 0, 0, 0 ]),
|
6 | addProps = require('./addProps');
|
7 |
|
8 | module.exports = function (rule, $) {
|
9 | var sel = rule[0],
|
10 | style = rule[1],
|
11 | selector = cssSelector(sel),
|
12 | editedElements = [];
|
13 |
|
14 | $(sel).each(function (index, el) {
|
15 | var cssText;
|
16 |
|
17 | if (!el.styleProps) {
|
18 | el.styleProps = {};
|
19 |
|
20 |
|
21 | if ($(el).attr('style')) {
|
22 | cssText = '* { ' + $(el).attr('style') + ' } ';
|
23 |
|
24 | addProps(el, parseCSS(cssText)[0][1], styleSelector);
|
25 | }
|
26 |
|
27 |
|
28 | editedElements.push(el);
|
29 | }
|
30 |
|
31 | addProps(el, style, selector);
|
32 | });
|
33 |
|
34 | return editedElements;
|
35 | };
|