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

feat($compile): Add support for ng-attr with camelcased attributes #10194

Closed
wants to merge 1 commit into from

Conversation

wesleycho
Copy link
Contributor

  • Modify $compile to handle camelcased attributes only with ng-attr to
    support SVG fully

This should address #9845.

@googlebot
Copy link

CLAs look good, thanks!

@wesleycho wesleycho force-pushed the feat/svg-camelcase branch 8 times, most recently from 4c65130 to 53a46ab Compare November 23, 2014 06:21
@@ -1405,7 +1405,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
// support ngAttr attribute binding
ngAttrName = directiveNormalize(name);
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
name = snake_case(ngAttrName.substr(6), '-');
name = name.replace(/^(data|x)-/, '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are ignoring other valid separators (:, _). There is a RegExp for that (PREFIX_REGEXP).

@petebacondarwin petebacondarwin added this to the ng-fixit #1 milestone Nov 23, 2014
- Modify $compile to handle camelcased attributes only with ng-attr to
  support SVG fully

- Change to svg to make clear it works

- Ensure the elements and attributes used are valid SVG elements & attributes

- Modify in attempt to use attribute IE is happy with

- Add specific SVG check for IE

- Fix incorrect attribute value used

Modification to re-run tests

- Break up line for jshint

- Fix codestyle

- Replace with prefix regexp

- Added more test cases to catch prefix regexp

- Add documentation in the guide on using underscores
petebacondarwin pushed a commit that referenced this pull request Dec 9, 2014
SVG attributes are case sensitive and some have upper case letters in them
This change ensures that we can identify these, when being used with the `ng-attr`
directive, by encoding upper case letters with a preceding underscore.

For example to apply `ng-attr` to the `viewBox` attribute we could write
`ng-attr-view_box` - or any of the other variants: `ng:attr:view_box`,
`data-ng-attr-view_box`, etc.

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

Successfully merging this pull request may close these issues.

4 participants