| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 function CSS(domAgent) { | 2 class CSS { |
| 3 this.domAgent_ = domAgent; | 3 constructor(domAgent) { |
| 4 } | 4 this.domAgent_ = domAgent; |
| 5 Object.preventExtensions(this); |
| 6 } |
| 5 | 7 |
| 6 CSS.prototype.enable = function() { | 8 enable() { |
| 7 }; | 9 } |
| 8 | 10 |
| 9 CSS.prototype.getInlineStylesForNode = function(params) { | 11 getInlineStylesForNode(params) { |
| 10 return { | 12 return { |
| 11 "inlineStyle": { | 13 "inlineStyle": { |
| 12 "cssProperties": [], | 14 "cssProperties": [], |
| 13 "shorthandEntries": [], | 15 "shorthandEntries": [], |
| 14 "styleSheetId": "0", | 16 "styleSheetId": "0", |
| 15 "range": { | 17 "range": { |
| 16 "startLine": 0, | 18 "startLine": 0, |
| 17 "startColumn": 0, | 19 "startColumn": 0, |
| 18 "endLine": 0, | 20 "endLine": 0, |
| 19 "endColumn": 0 | 21 "endColumn": 0 |
| 20 }, | 22 }, |
| 21 "cssText": "", | 23 "cssText": "", |
| 24 } |
| 25 }; |
| 26 } |
| 27 |
| 28 getComputedStyleForNode(params) { |
| 29 var node = this.domAgent_.getNodeForId(params.nodeId); |
| 30 if (!node){ |
| 31 console.log("Error, missing node" + params.nodeId); |
| 32 return { "computedStyle": [] }; |
| 22 } | 33 } |
| 34 var style = window.getComputedStyle(node, null); |
| 35 if (!style){ |
| 36 console.log("Error, no computed style for " + params.nodeId + " " + node); |
| 37 return { "computedStyle": [] }; |
| 38 } |
| 39 var computedStyles = []; |
| 40 for (var i = 0; i < style.length; i++) { |
| 41 var name = style.item(i); |
| 42 computedStyles.push({ |
| 43 "name": name, |
| 44 "value": style.getPropertyValue(name), |
| 45 }); |
| 46 } |
| 47 return { |
| 48 "computedStyle": computedStyles, |
| 49 }; |
| 23 } | 50 } |
| 24 } | 51 } |
| 25 | 52 |
| 26 CSS.prototype.getComputedStyleForNode = function(params) { | |
| 27 var node = this.domAgent_.getNodeForId(params.nodeId); | |
| 28 if (!node){ | |
| 29 console.log("Error, missing node" + params.nodeId); | |
| 30 return { "computedStyle": [] }; | |
| 31 } | |
| 32 var style = window.getComputedStyle(node, null); | |
| 33 if (!style){ | |
| 34 console.log("Error, no computed style for " + params.nodeId + " " + node); | |
| 35 return { "computedStyle": [] }; | |
| 36 } | |
| 37 var computedStyles = []; | |
| 38 for (var i = 0; i < style.length; i++) { | |
| 39 var name = style.item(i); | |
| 40 computedStyles.push({ | |
| 41 "name": name, | |
| 42 "value": style.getPropertyValue(name), | |
| 43 }); | |
| 44 } | |
| 45 return { | |
| 46 "computedStyle": computedStyles, | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 module.exports = CSS; | 53 module.exports = CSS; |
| 51 </script> | 54 </script> |
| OLD | NEW |