Skip to content

Allow dashes in element names #6

Closed
@billdami

Description

@billdami

Currently the function excludes any elements in the form that contain a dash in the name attribute, however using dashes are completely valid according the the W3C spec.

To include elements with dashed names in the returned object, I just updated the patterns.validate, patterns.key, and patterns.named regular expressions to include a dash in their character sets resulting in the following:

patterns = {
    validate: /^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
    key: /[a-zA-Z0-9_-]+|(?=\[\])/g,
    push: /^$/,
    fixed: /^\d+$/,
    named: /^[a-zA-Z0-9_-]+$/
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions