|
21 | 21 | import org.w3c.css.parser.analyzer.TokenMgrError;
|
22 | 22 | import org.w3c.css.properties.PropertiesLoader;
|
23 | 23 | import org.w3c.css.properties.css.CssProperty;
|
| 24 | +import org.w3c.css.properties.css3.CssCustomProperty; |
24 | 25 | import org.w3c.css.util.ApplContext;
|
25 | 26 | import org.w3c.css.util.CssVersion;
|
26 | 27 | import org.w3c.css.util.HTTPURL;
|
@@ -587,29 +588,32 @@ public CssProperty handleDeclaration(String property, CssExpression expression,
|
587 | 588 | if (Util.onDebug) {
|
588 | 589 | System.err.println("Creating " + property + ": " + expression);
|
589 | 590 | }
|
590 |
| - if (property.startsWith("--")) { |
| 591 | + |
| 592 | + if (property.startsWith("--") && (ac.getCssVersion().compareTo(CssVersion.CSS3) >= 0)) { |
| 593 | + prop = new CssCustomProperty(ac, property, expression); |
591 | 594 | // css variable
|
592 |
| - } |
593 |
| - final CssValue lastValue = expression.getLastValue(); |
| 595 | + } else { |
| 596 | + final CssValue lastValue = expression.getLastValue(); |
594 | 597 |
|
595 |
| - if (allowBackslash9Hack() && lastValue != null && lastValue.hasBackslash9Hack()) { |
596 |
| - expression.markCssHack(); |
597 |
| - } |
| 598 | + if (allowBackslash9Hack() && lastValue != null && lastValue.hasBackslash9Hack()) { |
| 599 | + expression.markCssHack(); |
| 600 | + } |
598 | 601 |
|
599 |
| - try { |
600 |
| - prop = properties.createProperty(ac, getAtRule(), property, expression); |
601 |
| - } catch (InvalidParamException e) { |
602 |
| - throw e; |
603 |
| - } catch (Exception e) { |
604 |
| - if (Util.onDebug) { |
605 |
| - e.printStackTrace(); |
| 602 | + try { |
| 603 | + prop = properties.createProperty(ac, getAtRule(), property, expression); |
| 604 | + } catch (InvalidParamException e) { |
| 605 | + throw e; |
| 606 | + } catch (Exception e) { |
| 607 | + if (Util.onDebug) { |
| 608 | + e.printStackTrace(); |
| 609 | + } |
| 610 | + throw new InvalidParamException(e.toString(), ac); |
606 | 611 | }
|
607 |
| - throw new InvalidParamException(e.toString(), ac); |
608 |
| - } |
609 | 612 |
|
610 |
| - // set the importance |
611 |
| - if (important) { |
612 |
| - prop.setImportant(); |
| 613 | + // set the importance |
| 614 | + if (important) { |
| 615 | + prop.setImportant(); |
| 616 | + } |
613 | 617 | }
|
614 | 618 | prop.setOrigin(origin);
|
615 | 619 | // set informations for errors and warnings
|
@@ -747,9 +751,9 @@ public void addCharSet(String charset) throws ParseException {
|
747 | 751 | if (charsetFromBOM && ac.getCssVersion().compareTo(CssVersion.CSS3) >= 0) {
|
748 | 752 | // TODO FIXME proper execption type.
|
749 | 753 | throw new ParseException(ac.getMsg().getString("parser.charset"));
|
750 |
| - // CssError cerr = new CssError(getSourceFile(), getBeginLine(), |
751 |
| - // getBeginColumn(), getEndLine(), getEndColumn(), ex); |
752 |
| - // ac.getFrame().addError(cerr); |
| 754 | + // CssError cerr = new CssError(getSourceFile(), getBeginLine(), |
| 755 | + // getBeginColumn(), getEndLine(), getEndColumn(), ex); |
| 756 | + // ac.getFrame().addError(cerr); |
753 | 757 | } else {
|
754 | 758 | Charset originalCharset = ac.getCharsetObjForURL(getURL());
|
755 | 759 | if (originalCharset == null) {
|
|
0 commit comments