Skip to content

Commit 4a371e6

Browse files
committed
polymer
1 parent 7dd30a7 commit 4a371e6

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

libraries/polymer/src/basic-tests.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ describe("basic support", function() {
124124
});
125125
});
126126

127+
describe("without properties", () => {
128+
it('will not overwrite unwriteable properties', function () {
129+
this.weight = 3;
130+
const root = document.createElement("component-without-properties");
131+
scratch.appendChild(root);
132+
const wc = root.shadowRoot.querySelector("#wc");
133+
expect(wc.getAttribute('amethod')).to.eql('method');
134+
expect(wc.getAttribute('agetter')).to.eql('getter');
135+
expect(wc.getAttribute('areadonly')).to.eql('readonly');
136+
expect(wc.innerHTML).to.eql('Success');
137+
})
138+
});
139+
127140
describe("events", function() {
128141
it("can imperatively listen to a DOM event dispatched by a Custom Element", async function() {
129142
this.weight = 3;

libraries/polymer/src/components.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import "./components/component-with-children.js";
33
import "./components/component-with-children-rerender.js";
44
import "./components/component-with-different-views.js";
55
import "./components/component-with-properties.js";
6+
import "./components/component-without-properties.js";
67
import "./components/component-with-imperative-event.js";
78
import "./components/component-with-declarative-event.js";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { PolymerElement, html } from "@polymer/polymer/polymer-element.js";
2+
import "ce-without-properties";
3+
4+
class ComponentWithoutProperties extends PolymerElement {
5+
static get is() {
6+
return "component-without-properties";
7+
}
8+
static get properties() {
9+
return {
10+
method: {
11+
type: String,
12+
value: 'method'
13+
},
14+
getter: {
15+
type: String,
16+
value: 'getter'
17+
},
18+
readonly: {
19+
type: String,
20+
value: 'readonly'
21+
},
22+
};
23+
}
24+
static get template() {
25+
return html`
26+
<div>
27+
<ce-without-properties id="wc"
28+
amethod="[[method]]"
29+
agetter="[[getter]]"
30+
readonly="[[readonly]]"
31+
></ce-without-properties>
32+
</div>
33+
`;
34+
}
35+
}
36+
window.customElements.define(
37+
ComponentWithoutProperties.is,
38+
ComponentWithoutProperties
39+
);

0 commit comments

Comments
 (0)