mirror of https://github.com/sveltejs/svelte
Support for complete property of img element. Fixes #5105
parent
ff6ce725bf
commit
b737530a76
@ -0,0 +1,65 @@
|
||||
/* generated by Svelte vX.Y.Z */
|
||||
import {
|
||||
SvelteComponent,
|
||||
add_render_callback,
|
||||
detach,
|
||||
element,
|
||||
init,
|
||||
insert,
|
||||
listen,
|
||||
noop,
|
||||
safe_not_equal
|
||||
} from "svelte/internal";
|
||||
|
||||
function create_fragment(ctx) {
|
||||
let img;
|
||||
let mounted;
|
||||
let dispose;
|
||||
|
||||
return {
|
||||
c() {
|
||||
img = element("img");
|
||||
if (/*complete*/ ctx[0] === void 0) add_render_callback(() => /*img_load_handler*/ ctx[1].call(img));
|
||||
},
|
||||
m(target, anchor) {
|
||||
insert(target, img, anchor);
|
||||
|
||||
if (!mounted) {
|
||||
dispose = listen(img, "load", /*img_load_handler*/ ctx[1]);
|
||||
mounted = true;
|
||||
}
|
||||
},
|
||||
p: noop,
|
||||
i: noop,
|
||||
o: noop,
|
||||
d(detaching) {
|
||||
if (detaching) detach(img);
|
||||
mounted = false;
|
||||
dispose();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function instance($$self, $$props, $$invalidate) {
|
||||
let { complete } = $$props;
|
||||
|
||||
function img_load_handler() {
|
||||
complete = this.complete;
|
||||
$$invalidate(0, complete);
|
||||
}
|
||||
|
||||
$$self.$set = $$props => {
|
||||
if ("complete" in $$props) $$invalidate(0, complete = $$props.complete);
|
||||
};
|
||||
|
||||
return [complete, img_load_handler];
|
||||
}
|
||||
|
||||
class Component extends SvelteComponent {
|
||||
constructor(options) {
|
||||
super();
|
||||
init(this, options, instance, create_fragment, safe_not_equal, { complete: 0 });
|
||||
}
|
||||
}
|
||||
|
||||
export default Component;
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let complete;
|
||||
</script>
|
||||
|
||||
<img bind:complete/>
|
||||
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"code": "invalid-binding",
|
||||
"message": "'complete' binding can only be used with <img>",
|
||||
"pos": 40,
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 5,
|
||||
"character": 40
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 18,
|
||||
"character": 53
|
||||
}
|
||||
}]
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let complete;
|
||||
</script>
|
||||
|
||||
<div bind:complete></div>
|
||||
Loading…
Reference in new issue