Skip to content

Meta tags with same name attribute but different other attributes will be overwritten #34

@GoodbyeNJN

Description

@GoodbyeNJN

For example, use the following two tags:

<Meta name="theme-color" media="(prefers-color-scheme: light)" content="#fff" />
<Meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000" />

Only the latter will actually be rendered.

The problem lies here:

solid-meta/src/index.tsx

Lines 156 to 170 in c9d21ef

actions.addServerTag = (tagDesc: TagDescription) => {
const { tags = [] } = props;
// tweak only cascading tags
if (cascadingTags.indexOf(tagDesc.tag) !== -1) {
const index = tags.findIndex(prev => {
const prevName = prev.props.name || prev.props.property;
const nextName = tagDesc.props.name || tagDesc.props.property;
return prev.tag === tagDesc.tag && prevName === nextName;
});
if (index !== -1) {
tags.splice(index, 1);
}
}
tags.push(tagDesc);
};

This function seems to remove duplicate tags, but only name or property attributes are compared when checking whether they are duplicates.

I suppose to sort props by key and then serialize it as the unique key of a tag for comparison.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions