Open Bug 1840320 Opened 1 year ago Updated 1 year ago

Add InspectorUtils.parseCSSDeclarations

Categories

(DevTools :: Inspector, task)

task

Tracking

(Not tracked)

People

(Reporter: nchevobbe, Unassigned, NeedInfo)

References

Details

This new methods would replace DevTools custom parseDeclarationsInternal (parsing-utils.js)

The function takes a string input which represent the "body" of a rule and returns an array of declarations object, with the following properties:

  • {String} name: The name of the property
  • {String} value: The value for the property
  • {String} priority: "important" or empty string (this one could be turned into an boolean important property I guess? Not sure why we have it as a string)
  • {String} terminator: the string to use to terminate the declaration
  • {Array<int>} colonOffsets: An array of 2 integers, holding the start and end locations of the ":" that separates the property name from the value.
  • {Array<int>} offset: An array of 2 integers, which are the index in the input string at which the declaration starts and ends (so calling substring on the input will give us the authored property)
  • {Array<int>} commentOffsets: If the declaration appears in a comment, an array of 2 integers which will hold the offsets of the start and end of the enclosing comment input will give us the authored property)
  • {bool} isNameValid: true if the property is valid
  • {bool} isValid: Is the whole declaration valid

One thing that we didn't decide on yet is if we want to also get the "nested rules declarations", so we could maybe display them as well in the rule view for easier authoring (see Bug 1838179)

Flags: needinfo?(emilio)
You need to log in before you can comment on or make changes to this bug.