schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs and SSR.
https://jasprpad.schultek.de
MIT License
996 stars 59 forks source link

fix: Extend allowed characters to DomValidator #214

Closed walsha2 closed 3 months ago

walsha2 commented 3 months ago

Description

Take the following, valid, Alpine.js use case:

<div ... x-on:click.outside="open = false">Contents...</div>

This will throw a server error:

[SERVER] [ERROR] Invalid argument(s): "x-on:click.outside" is not a valid attribute name.
[SERVER] [ERROR] package:jaspr/src/server/markup_render_object.dart 165:7   DomValidator.validateAttributeName

Doctor Output

Using the latest main branch revisions of all jaspr apps.

Discussion

packages/jaspr/lib/src/server/markup_render_object.dart

The following modification should resolve the issue:

  static final _attributeRegExp =
      RegExp(r'^[a-z](?:[a-zA-Z0-9\-_:.]*[a-z0-9]+)?$');

This modification allows for . to appear anywhere in the string along with the other special characters.

With this change, the following string is now valid: x-on:click.outside