opensubscriber
   Find in this group all groups
 
Unknown more information…

d : dev-tech-layout@lists.mozilla.org 20 April 2012 • 7:12PM -0400

Validating css property values
by Mike Ratcliffe

REPLY TO AUTHOR
 
REPLY TO GROUP




As part of our css devtools we need a way to check that a css property value is valid. This is used to validate the value onkeyup. Our current solution is to call the following method on each keypress:

  function validate(aValue)
  {
    let name = this.prop.name;
    let value = typeof aValue == "undefined" ? this.prop.value : aValue;
    let style = this.doc.createElementNS(HTML_NS, "div").style;

    style.setProperty(name, value, null);

    return !!style.getPropertyValue(name);
   },

The problem with this solution is that it spews css error messages for invalid property values, but we could work around this with:

  let prefVal = getPref("layout.css.report_errors");
  setPref("layout.css.report_errors", false);
  try {
    style.setProperty(name, value, null);
  } finally {
    setPref("layout.css.report_errors, prefVal");
  }

It occurs to me that we are also adding autocomplete to the properties, so can any of you guys think of:
1. A better way to validate css property values.
2. A way to get a list of possible property values for a given css property (this could be used for autocomplete and validation).
3. A better way to do both 1 and 2 ;o)

~Mike Ratcliffe
_______________________________________________
dev-tech-layout mailing list
dev-tech-layout@list...
https://lists.mozilla.org/listinfo/dev-tech-layout

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.