Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

refactor: utils should have a function to get all prefixed attributes #8121

@devversion

Description

@devversion

We need a util method, which returns all prefixed attributes.

#getPrefixedAttributes

$mdUtil.getPrefixedAttributes('ng-click');
// Returns ['ng-click', 'data-ng-click', 'x-ng-click']

#hasPrefixedAttribute

var el = angular.element('<div data-ng-click="null">');

$mdUtil.hasPrefixedAttribute(el, 'ng-click');
// Returns true;

#getPrefixedAttributeSelector

$mdUtil.getPrefixedAttributeSelector(['ng-click', 'ng-mouseenter']);
// Returns [ng-click], [data-ng-click], [x-ng-click], [ng-mouseenter], 
// [data-ng-mouseenter], [x-ng-mouseenter]
  • We query really often for elements with attributes (but not with prefixed)
  • We often copy attributes to another element and need to specify the prefixed attributes manually.
  • Sometimes we want to know if an element has an attribute (even with prefixed attrs)

We repeat the same code really often for different components, like list, menu etc.

Metadata

Metadata

Assignees

Labels

has: Pull RequestA PR has been created to address this issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions