[2.0.0-beta2] The regex for attribute props should allow the hyphen ("-") symbol

Created on 10 September 2024, 2 months ago
Updated 15 September 2024, 2 months ago

Problem/Motivation

I’m using Tailwind in my project, and as you know, most Tailwind classes contain hyphens ("-"). When I try to pass these classes through the attributes prop in a component element, the form validation rejects all the classes with hyphens. After investigating, I found that the regex used in the AttributesWidget::buildRegexPattern method doesn’t allow hyphens, it only permits words and spaces.

Additionally, for attribute names, why limit them to only alphabetic characters? Hyphens are commonly used in attribute names, especially for data attributes, such as data-slider="3"

Proposed resolution

Allow hyphens in both the regex for attribute names and attribute values

in AttributesWidget::buildRegexPattern method definition update the regex from:

    // Attribute names are a mix of ASCII lower and upper alphas.
    $attr_name = "[a-zA-Z]+";
    // Allow anything in attributes values, which are between double quotes.
    $double_quoted_value = '"[\s\w]*"';

to:

    // Attribute names are a mix of ASCII lower and upper alphas.
    $attr_name = "[a-zA-Z\-]+";
    // Allow anything in attributes values, which are between double quotes.
    $double_quoted_value = '"[\s\w\-]*"';
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡²πŸ‡¦Morocco b.khouy πŸ‡²πŸ‡¦ Morocco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024