Skip to content

Commit fad26b8

Browse files
committed
refactor: Do not manually call connectedCallback
1 parent 986f340 commit fad26b8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { h, cloneElement, render, hydrate } from 'preact';
44
* @typedef {import('./index.d.ts').PreactCustomElement} PreactCustomElement
55
*/
66

7-
87
/**
98
* @type {import('./index.d.ts').default}
109
*/
@@ -56,7 +55,6 @@ export default function register(Component, tagName, propNames, options) {
5655
} else {
5756
if (!this._props) this._props = {};
5857
this._props[name] = v;
59-
this.connectedCallback();
6058
}
6159

6260
// Reflect property changes to attributes if the value is a primitive

src/index.test.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ describe('web components', () => {
5959
it('passes property changes to props', () => {
6060
const el = document.createElement('x-clock');
6161

62+
root.appendChild(el);
63+
6264
el.time = '10:28:57 PM';
6365
assert.equal(el.time, '10:28:57 PM');
6466

65-
root.appendChild(el);
6667
assert.equal(
6768
root.innerHTML,
6869
'<x-clock time="10:28:57 PM"><span>10:28:57 PM</span></x-clock>'
@@ -86,10 +87,11 @@ describe('web components', () => {
8687
it('passes simple properties changes to props', () => {
8788
const el = document.createElement('x-dummy-button');
8889

90+
root.appendChild(el);
91+
8992
el.text = 'foo';
9093
assert.equal(el.text, 'foo');
9194

92-
root.appendChild(el);
9395
assert.equal(
9496
root.innerHTML,
9597
'<x-dummy-button text="foo"><button>foo</button></x-dummy-button>'
@@ -108,10 +110,12 @@ describe('web components', () => {
108110

109111
let clicks = 0;
110112
const onClick = () => clicks++;
113+
114+
root.appendChild(el);
115+
111116
el.onClick = onClick;
112117
assert.equal(el.onClick, onClick);
113118

114-
root.appendChild(el);
115119
assert.equal(
116120
root.innerHTML,
117121
'<x-dummy-button><button>click</button></x-dummy-button>'
@@ -327,8 +331,7 @@ describe('web components', () => {
327331

328332
const child = document
329333
.querySelector('x-adopted-style-sheets')
330-
.shadowRoot
331-
.querySelector('.styled-child');
334+
.shadowRoot.querySelector('.styled-child');
332335

333336
const style = getComputedStyle(child);
334337
assert.equal(style.color, 'rgb(255, 0, 0)');

0 commit comments

Comments
 (0)