diff --git a/demo/index.html b/demo/index.html
index fc72496..27df8c2 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -32,6 +32,12 @@
Pre-assigned rating demo
+ Readonly demo
+
+
+
+
+
Custom icon demo
diff --git a/iron-star-rating.html b/iron-star-rating.html
index 98ffedb..091669e 100644
--- a/iron-star-rating.html
+++ b/iron-star-rating.html
@@ -8,10 +8,12 @@
@@ -67,6 +69,7 @@
return {
value: {
type: Number,
+ value: 0,
notify: true,
observer: '_valueChanged'
},
@@ -77,6 +80,11 @@
disableAutoUpdate: {
type: Boolean,
value: false,
+ },
+ readonly: {
+ type: Boolean,
+ value: false,
+ reflectToAttribute: true,
}
};
}
@@ -120,6 +128,10 @@
_starClicked(e) {
e.preventDefault();
+ if (this.readonly) {
+ return;
+ }
+
if (!this.disableAutoUpdate) {
this.value = e.model.item.value;
}
diff --git a/test/iron-star-rating_test.html b/test/iron-star-rating_test.html
index 80d15ca..e6a8388 100644
--- a/test/iron-star-rating_test.html
+++ b/test/iron-star-rating_test.html
@@ -19,9 +19,15 @@
-
+
-
+
+
+
+
+
+
+
@@ -30,19 +36,18 @@
test('instantiating the element with default properties works', function() {
var element = fixture('BasicTestFixture');
- assert.equal(element.prop1, 'iron-star-rating');
- var elementShadowRoot = element.shadowRoot;
- var elementHeader = elementShadowRoot.querySelector('h2');
- assert.equal(elementHeader.innerHTML, 'Hello iron-star-rating!');
+ assert.equal(element.value, 0);
+ assert.equal(element.readonly, false);
+ });
+
+ test('setting a value on the element works', function() {
+ var element = fixture('InitialValueTestFixture');
+ assert.equal(element.value, 3);
});
- test('setting a property on the element works', function() {
- // Create a test fixture
- var element = fixture('ChangedPropertyTestFixture');
- assert.equal(element.prop1, 'new-prop1');
- var elementShadowRoot = element.shadowRoot;
- var elementHeader = elementShadowRoot.querySelector('h2');
- assert.equal(elementHeader.innerHTML, 'Hello new-prop1!');
+ test('setting readonly on the element works', function() {
+ var element = fixture('ReadonlyTestFixture');
+ assert.equal(element.readonly, true);
});
});