Skip to content

Commit d45dd57

Browse files
committed
Put attribute capitalization fix in property-effects
1 parent 37fd5ff commit d45dd57

File tree

7 files changed

+46
-202
lines changed

7 files changed

+46
-202
lines changed

externs/closure-types.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,19 +1374,4 @@ Polymer_ArraySelectorMixin.prototype.select = function(item){};
13741374
* @param {number} idx Index from `items` array to select
13751375
* @return {void}
13761376
*/
1377-
Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){};
1378-
/**
1379-
* @interface
1380-
* @extends {Polymer_PropertyEffects}
1381-
*/
1382-
function Polymer_AttributeCapitalization(){}
1383-
/**
1384-
* @override
1385-
* @param {Node} node Node to parse
1386-
* @param {TemplateInfo} templateInfo Template metadata for current template
1387-
* @param {NodeInfo} nodeInfo Node metadata for current template node
1388-
* @param {*} name
1389-
* @param {*} value
1390-
* @return {boolean}
1391-
*/
1392-
Polymer_AttributeCapitalization._parseTemplateNodeAttribute = function(node, templateInfo, nodeInfo, name, value){};
1377+
Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){};

lib/mixins/property-effects.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
READ_ONLY: '__readOnly'
4444
};
4545

46+
/** @const {string} */
47+
const capitalAttributeRegex = /[A-Z]/;
48+
4649
/**
4750
* @typedef {{
4851
* name: (string | undefined),
@@ -2530,7 +2533,9 @@
25302533
// Attribute or property
25312534
let origName = name;
25322535
let kind = 'property';
2533-
if (name[name.length-1] == '$') {
2536+
if (capitalAttributeRegex.test(name)) {
2537+
kind = 'attribute';
2538+
} else if (name[name.length-1] == '$') {
25342539
name = name.slice(0, -1);
25352540
kind = 'attribute';
25362541
}

lib/utils/attribute-capitalization-mixin.html

Lines changed: 0 additions & 80 deletions
This file was deleted.

test/unit/attribute-capitalization.html

Lines changed: 0 additions & 58 deletions
This file was deleted.

test/unit/property-effects-elements.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Code distributed by Google as part of the polymer project is also
88
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
99
-->
10+
<link rel="import" href="../../polymer.html">
11+
1012
<dom-module id="x-basic">
1113
<template>
1214
<div id="boundChild"
@@ -1062,3 +1064,23 @@
10621064
}
10631065
customElements.define(SubObserverElement.is, SubObserverElement);
10641066
</script>
1067+
1068+
<dom-module id="svg-element">
1069+
<template>
1070+
<svg id="svg" viewBox="[[value]]"></svg>
1071+
</template>
1072+
<script>
1073+
class SVGElement extends Polymer.Element {
1074+
static get is() { return 'svg-element'; }
1075+
static get properties() {
1076+
return {
1077+
value: {
1078+
type: String,
1079+
value: '0 0 50 50'
1080+
}
1081+
};
1082+
}
1083+
}
1084+
customElements.define(SVGElement.is, SVGElement);
1085+
</script>
1086+
</dom-module>

test/unit/property-effects.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,23 @@
419419
assert.equal(el.__observerCalled, 1);
420420
});
421421
});
422+
423+
suite('automated attribute capitalization detection', function() {
424+
let el;
425+
426+
setup(function() {
427+
el = document.createElement('svg-element');
428+
document.body.appendChild(el);
429+
});
430+
431+
teardown(function() {
432+
document.body.removeChild(el);
433+
});
434+
435+
test('can handle capitalized HTML attribute', function() {
436+
assert.equal(el.$.svg.getAttribute('viewBox'), el.value);
437+
});
438+
});
422439
});
423440

424441
suite('computed bindings with dynamic functions', function() {

types/lib/utils/attribute-capitalization-mixin.d.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)