Skip to content

Commit

Permalink
Merge pull request #2 from PolymerLabs/es6
Browse files Browse the repository at this point in the history
Es6
  • Loading branch information
kevinpschaaf committed Apr 8, 2016
2 parents f81edca + 1448df0 commit fa604cc
Show file tree
Hide file tree
Showing 39 changed files with 1,006 additions and 1,108 deletions.
13 changes: 5 additions & 8 deletions all-lib.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<link rel="import" href="src/attributes/attribute-to-property.html">
<link rel="import" href="src/attributes/property-to-attribute.html">
<link rel="import" href="src/attributes/attribute-to-from-property.html">

<link rel="import" href="src/events/event-dispatch.html">
<link rel="import" href="src/events/gesture-event-listeners.html">
<link rel="import" href="src/events/gestures.html">
<link rel="import" href="src/events/event-listeners.html">

<link rel="import" href="src/template/template.html">
<link rel="import" href="src/template/template-stamp.html">

<link rel="import" href="src/properties/property-accessors.html">
<link rel="import" href="src/properties/property-effects.html">
<link rel="import" href="src/properties/data.html">
<link rel="import" href="src/properties/batched-effects.html">
15 changes: 0 additions & 15 deletions polymer.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
<!-- <link rel="import" href="src/utils/case-map.html">
<link rel="import" href="src/template/template.html">
<link rel="import" href="src/template/annotations.html">
<link rel="import" href="src/template/resolveUrl.html">
<link rel="import" href="src/properties/effectBuilder.html">
<link rel="import" href="src/properties/accessors.html">
<link rel="import" href="src/properties/effects.html">
<link rel="import" href="src/properties/notify-path.html">
<link rel="import" href="src/events/events.html">
<link rel="import" href="src/events/gestures.html">
<link rel="import" href="src/attributes/attributes.html"> -->
<!-- -->
<!-- <link rel="import" href="src/configure/ready.html">
<link rel="import" href="src/configure/configure.html"> -->

<link rel="import" href="src/compat/polymer-fn.html">
<link rel="import" href="src/compat/base.html">
<link rel="import" href="src/compat/dom-module.html">
Expand Down
8 changes: 2 additions & 6 deletions size.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
echo 'property-effects ' && polybuild --maximum-crush src/properties/property-effects.html && gzip -c src/properties/property-effects.build.js | wc -c && rm src/properties/property-effects.build.*
echo 'all-lib ' && polybuild all-lib.html && gzip -c all-lib.build.js | wc -c && rm all-lib.build.*

echo 'gesture-event-listeners ' && polybuild --maximum-crush src/events/gesture-event-listeners.html && gzip -c src/events/gesture-event-listeners.build.js | wc -c && rm src/events/gesture-event-listeners.build.*

echo 'all-lib ' && polybuild --maximum-crush all-lib.html && gzip -c all-lib.build.js | wc -c && rm all-lib.build.*

echo 'polymer ' && polybuild --maximum-crush polymer.html && gzip -c polymer.build.js | wc -c && rm polymer.build.*
echo 'polymer ' && polybuild polymer.html && gzip -c polymer.build.js | wc -c && rm polymer.build.*
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/case-map.html">
<link rel="import" href="attribute-to-property.html">

<script>
(function() {
Expand All @@ -19,7 +20,20 @@
// 'import'
var CaseMap = Polymer.CaseMap;

var PropertyToAttribute = {
class AttributeToFromProperty extends Polymer.AttributeToProperty {

/* apply attributes to node but avoid overriding existing values */
ensureAttributes(node, attr$) {
for (var attr in attr$) {
this.ensureAttribute(node, attr, attr$[attr])
}
}

ensureAttribute(node, attr, value) {
if (!node.hasAttribute(attr)) {
this.valueToAttribute(node, value, attr);
}
}

/**
* Serializes a property to its associated attribute.
Expand All @@ -30,13 +44,13 @@
* @param {*=} value Property value to refect.
*/
// TODO(sorvell): only needed by property setters
propertyToAttribute: function(node, property, attribute, value) {
propertyToAttribute(node, property, attribute, value) {
this._serializing = true;
value = (value === undefined) ? node[property] : value;
this.valueToAttribute(node, value,
attribute || CaseMap.camelToDashCase(property));
this._serializing = false;
},
}

/**
* Sets a typed value to an HTML attribute on a node.
Expand All @@ -52,14 +66,14 @@
* @param {string} attribute Attribute name to serialize to.
*/
valueToAttribute: function(node, value, attribute) {
valueToAttribute(node, value, attribute) {
var str = this.serialize(value);
if (str === undefined) {
node.removeAttribute(attribute);
} else {
node.setAttribute(attribute, str);
}
},
}

/**
* Converts a typed value to a string.
Expand All @@ -72,7 +86,7 @@
* @param {*} value Property value to serialize.
* @return {string} String serialized from the provided property value.
*/
serialize: function(value) {
serialize(value) {
/* eslint-disable no-fallthrough */
switch (typeof value) {
case 'boolean':
Expand All @@ -94,10 +108,10 @@
}
}
/* eslint-enable no-fallthrough */
};
}

// export
Polymer.PropertyToAttribute = PropertyToAttribute;
Polymer.AttributeToFromProperty = AttributeToFromProperty;

})();
</script>
19 changes: 10 additions & 9 deletions src/attributes/attribute-to-property.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
// 'import'
var CaseMap = Polymer.CaseMap;

var AttributeToProperty = {
class AttributeToProperty {

// for reflecting initial state of attributes to properties.
attributesToProperties: function(node, map, model) {
attributesToProperties(node, map, model) {
model = model || node;
if (node.hasAttributes()) {
for (var prop in map) {
Expand All @@ -33,24 +33,24 @@
}
}
}
},
}

// for attributeChangedCallback
attributeToProperty: function(node, attribute, property, type, model) {
attributeToProperty(node, attribute, property, type, model) {
model = model || node;
// Don't deserialize back to property if currently reflecting
if (!node._serializing) {
model[property] = this.valueForAttribute(node, attribute, property, type);
}
},
}

valueForAttribute: function(node, attribute, property, type) {
valueForAttribute(node, attribute, property, type) {
property = (property || CaseMap.dashToCamelCase(attribute));
if (node.hasAttribute(attribute)) {
var value = node.getAttribute(attribute);
return this.deserialize(value, type);
}
},
}

/**
* Converts a string to a typed value.
Expand All @@ -71,7 +71,7 @@
* @return {*} Typed value deserialized from the provided string.
*/
// TODO(sorvell): should the base impl only support String?
deserialize: function(value, type) {
deserialize(value, type) {
switch (type) {
case Number:
value = Number(value);
Expand Down Expand Up @@ -108,7 +108,8 @@
}
return value;
}
};

}

// export
Polymer.AttributeToProperty = AttributeToProperty;
Expand Down
126 changes: 0 additions & 126 deletions src/attributes/compat-attributes.html

This file was deleted.

Loading

0 comments on commit fa604cc

Please sign in to comment.