addRule method

Future<CSSRule> addRule(
  1. StyleSheetId styleSheetId,
  2. String ruleText,
  3. SourceRange location, {
  4. NodeId? nodeForPropertySyntaxValidation,
})

Inserts a new rule with the given ruleText in a stylesheet with given styleSheetId, at the position specified by location. styleSheetId The css style sheet identifier where a new rule should be inserted. ruleText The text of a new rule. location Text position of a new rule in the target style sheet. nodeForPropertySyntaxValidation NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example. Returns: The newly created rule.

Implementation

Future<CSSRule> addRule(
    StyleSheetId styleSheetId, String ruleText, SourceRange location,
    {dom.NodeId? nodeForPropertySyntaxValidation}) async {
  var result = await _client.send('CSS.addRule', {
    'styleSheetId': styleSheetId,
    'ruleText': ruleText,
    'location': location,
    if (nodeForPropertySyntaxValidation != null)
      'nodeForPropertySyntaxValidation': nodeForPropertySyntaxValidation,
  });
  return CSSRule.fromJson(result['rule'] as Map<String, dynamic>);
}