Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

Add CSS selector for TagHelper required attributes. #418

Open
NTaylorMullen opened this issue Mar 8, 2016 · 3 comments
Open

Add CSS selector for TagHelper required attributes. #418

NTaylorMullen opened this issue Mar 8, 2016 · 3 comments

Comments

@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Mar 8, 2016

With the completion of aspnet/Razor#684 TagHelpers can now determine their application on an HTML element based on an attribute name and its value.

The following CSS selector attributes were added:

  1. [name^=value] : HTML element must have an attribute with name (case insensitive) and a value that starts with value (case sensitive).
  2. [name$=value] : HTML element must have an attribute with name (case insensitive) and a value that ends with value (case sensitive).
  3. [name=value] : HTML element must have an attribute with name (case insensitive) and a value that equals value (case sensitive).

Full list here. We haven't added support for all of them, just the ones listed above.

Any attribute value with a dynamic value such as type="prefix @something suffix" would result in the following:

  1. [type^=prefix] = Matches ✅
  2. [type$=suffix] = Matches ✅
  3. [type='prefix @something suffix'] = Does not match ❌

This is because dynamic values are treated as unmatchable pieces of an attribute value.

I've abstracted the logic for the selector matching criteria into a TagHelperDescriptors RequiredAttributes. Each RequiredAttribute is of type TagHelperRequiredAttributeDescriptor and has an IsMatch method which takes care of all of the criteria.

@sayedihashimi
Copy link
Contributor

Assigned to @madskristensen

@sayedihashimi
Copy link
Contributor

TFS Bug#231166

@webtools-bot
Copy link

The GitHub Issue Tracker for the aspnet/Tooling repo is being deprecated in favor of Visual Studio's Report a Problem tool.

If this issue is still a problem with the RTW release of Visual Studio 2017, please report a new issue using the Report a Problem tool. While you can still use .NET Core and ASP.NET Preview tools with Visual Studio 2015, Visual Studio 2017 is now the officially supported tool for developing .NET Core and ASP.NET Core projects.

By using the Report a Problem tool (available in both VS 2017 and VS 2015), you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks. See Visual Studio's Talk to Us page for more details.

Please use the discussion topic here for feedback and questions on the deprecation of this issue tracker. Thanks!

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

No branches or pull requests

4 participants