Skip to content

Commit

Permalink
Fix a bug in justify-self parsing where in auto | normal | stretch | …
Browse files Browse the repository at this point in the history
…<baseline-position> | <overflow-position>? [ <self-position> | left | right ]

the <overflow-position> [left | right] and <self-position> parsing were missing.
Fixed a bug where delegating parsing of the justify-self part forgot first extra value before parsing -> recreate a new expression before proceeding.

This should fix #338
  • Loading branch information
ylafon committed Oct 1, 2021
1 parent bd347b0 commit 92b6fb6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 15 additions & 1 deletion org/w3c/css/properties/css3/CssJustifySelf.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/**
* @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-justify-self
* @see CssAlignSelf
*/
public class CssJustifySelf extends org.w3c.css.properties.css.CssJustifySelf {

Expand Down Expand Up @@ -149,7 +150,20 @@ public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression
throw new InvalidParamException("value", val.toString(),
caller.getPropertyName(), ac);
}
if (getSelfPositionAddExtras(val.getIdent()) == null) {
if ((CssAlignSelf.getSelfPosition(val.getIdent()) == null)
&& (getSelfPositionAddExtras(val.getIdent()) == null)) {
throw new InvalidParamException("value", val.toString(),
caller.getPropertyName(), ac);
}
values.add(val);
expression.next();
return new CssValueList(values);
} else {
if (val.getType() != CssTypes.CSS_IDENT) {
throw new InvalidParamException("value", val.toString(),
caller.getPropertyName(), ac);
}
if (CssAlignSelf.getSelfPosition(val.getIdent()) == null) {
throw new InvalidParamException("value", val.toString(),
caller.getPropertyName(), ac);
}
Expand Down
14 changes: 9 additions & 5 deletions org/w3c/css/properties/css3/CssPlaceSelf.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public CssPlaceSelf() {
* Creates a new CssAlignSelf
*
* @param expression The expression for this property
* @throws org.w3c.css.util.InvalidParamException
* Expressions are incorrect
* @throws org.w3c.css.util.InvalidParamException Expressions are incorrect
*/
public CssPlaceSelf(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
Expand Down Expand Up @@ -66,9 +65,14 @@ public CssPlaceSelf(ApplContext ac, CssExpression expression, boolean check)
}
values.add(val);
alignSelf.value = val;

val = CssJustifySelf.parseJustifySelf(ac, expression, this);
if (!expression.end()) {
CssExpression ex = new CssExpression();
while (!expression.end()) {
ex.addValue(expression.getValue());
ex.setOperator(expression.getOperator());
expression.next();
}
val = CssJustifySelf.parseJustifySelf(ac, ex, this);
if (!ex.end()) {
throw new InvalidParamException("value", expression.getValue().toString(),
getPropertyName(), ac);
}
Expand Down

0 comments on commit 92b6fb6

Please sign in to comment.