Upgrade & pin Preact version

This commit is contained in:
Ingvar Stepanyan
2022-01-17 20:12:37 +00:00
parent ee5732b3a2
commit 473e41f423
2 changed files with 11 additions and 22 deletions

View File

@@ -38,9 +38,9 @@
<script type="importmap">
{
"imports": {
"preact": "https://unpkg.com/preact/dist/preact.module.js",
"preact/debug": "https://unpkg.com/preact/debug/dist/debug.module.js",
"preact/devtools": "https://unpkg.com/preact@10.5.14/devtools/dist/devtools.module.js",
"preact": "https://unpkg.com/preact@10.6.4/dist/preact.module.js",
"preact/debug": "https://unpkg.com/preact@10.6.4/debug/dist/debug.module.js",
"preact/devtools": "https://unpkg.com/preact@10.6.4/devtools/dist/devtools.module.js",
"stats.js": "https://unpkg.com/stats.js@0.17.0/src/Stats.js"
}
}

View File

@@ -142,11 +142,14 @@ export class Widget extends Component {
'select',
attrs,
choices.map(choice =>
h(Option, {
h(
'option',
{
key: choice,
value: choice,
disabled: attrs.readonly && value !== choice
})
},
choice
)
)
);
break;
@@ -172,20 +175,6 @@ export class Widget extends Component {
}
}
/**
* Special memoized option to work around https://github.com/preactjs/preact/issues/3171.
* @extends Component<{ value: string, disabled?: boolean }>
*/
class Option extends Component {
shouldComponentUpdate(/** @type {Option['props']} */ nextProps) {
return nextProps.value !== this.props.value;
}
render() {
return h('option', this.props, this.props.value);
}
}
/**
* Wrapper around <input /> that doesn't update it while it's in focus to allow editing.
*/