Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-align literals are outdated #340

Open
DeepSnowNeeL opened this issue May 24, 2024 · 0 comments
Open

text-align literals are outdated #340

DeepSnowNeeL opened this issue May 24, 2024 · 0 comments

Comments

@DeepSnowNeeL
Copy link

On CssSchema (

)

 Property textAlign = new Property(0, union(azimuthLiterals1, textAlignLiterals0), zeroFns);
        builder.put("text-align", textAlign);

The text-align possible values are (https://developer.mozilla.org/en-US/docs/Web/CSS/text-align ) :

text-align: start;
text-align: end;
text-align: left;
text-align: right;
text-align: center;
text-align: justify;
text-align: justify-all;
text-align: match-parent;

/* Block alignment values (Non-standard syntax) */
text-align: -moz-center;
text-align: -webkit-center;

/* Global values */
text-align: inherit;
text-align: initial;
text-align: revert;
text-align: revert-layer;
text-align: unset;

And only 5 of them are kept when sanitizing right now : left, right, center, inherit, justify

I did a dirty hack for the moment to cover my needs:

try {
        CssSchema cssSchema = CssSchema.DEFAULT;
	Method forKey = cssSchema.getClass().getDeclaredMethod("forKey", String.class);
	forKey.setAccessible(true);
	CssSchema.Property p = (CssSchema.Property) forKey.invoke(union, "text-align");
	Field literalsField = p.getClass().getDeclaredField("literals");
	literalsField.setAccessible(true);
	Set<String> literals = new HashSet<>((Set<String>) literalsField.get(p));
	literals.add("start");
	literals.add("end");
	literalsField.set(p, literals);
} catch (Exception e) {
	...
}

The literals of other css properties might be outdated too, I didn't check but it might be needed to review all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant