-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] fix 'src' attribute judge logic (#6575) #6580
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
options: { | ||
hydratable: true | ||
} | ||
}; |
70 changes: 70 additions & 0 deletions
70
test/js/samples/src-attribute-check-in-foreign/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* generated by Svelte vX.Y.Z */ | ||
import { | ||
SvelteComponent, | ||
append_hydration, | ||
attr, | ||
children, | ||
claim_element, | ||
detach, | ||
init, | ||
insert_hydration, | ||
noop, | ||
safe_not_equal | ||
} from "svelte/internal"; | ||
|
||
function create_fragment(ctx) { | ||
let svg; | ||
let img; | ||
|
||
return { | ||
c() { | ||
svg = document.createElementNS("https://svelte.dev/docs#svelte_options", "svg"); | ||
img = document.createElementNS("https://svelte.dev/docs#svelte_options", "img"); | ||
this.h(); | ||
}, | ||
l(nodes) { | ||
svg = claim_element(nodes, "svg", {}); | ||
var svg_nodes = children(svg); | ||
img = claim_element(svg_nodes, "img", { alt: true, src: true }); | ||
svg_nodes.forEach(detach); | ||
this.h(); | ||
}, | ||
h() { | ||
attr(img, "alt", "potato"); | ||
attr(img, "src", /*url*/ ctx[0]); | ||
}, | ||
m(target, anchor) { | ||
insert_hydration(target, svg, anchor); | ||
append_hydration(svg, img); | ||
}, | ||
p(ctx, [dirty]) { | ||
if (dirty & /*url*/ 1) { | ||
attr(img, "src", /*url*/ ctx[0]); | ||
} | ||
}, | ||
i: noop, | ||
o: noop, | ||
d(detaching) { | ||
if (detaching) detach(svg); | ||
} | ||
}; | ||
} | ||
|
||
function instance($$self, $$props, $$invalidate) { | ||
let { url } = $$props; | ||
|
||
$$self.$$set = $$props => { | ||
if ('url' in $$props) $$invalidate(0, url = $$props.url); | ||
}; | ||
|
||
return [url]; | ||
} | ||
|
||
class Component extends SvelteComponent { | ||
constructor(options) { | ||
super(); | ||
init(this, options, instance, create_fragment, safe_not_equal, { url: 0 }); | ||
} | ||
} | ||
|
||
export default Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<svelte:options namespace="foreign" /> | ||
|
||
<script> | ||
export let url; | ||
</script> | ||
|
||
<svg> | ||
<img alt="potato" src={url}> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
options: { | ||
hydratable: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* generated by Svelte vX.Y.Z */ | ||
import { | ||
SvelteComponent, | ||
append_hydration, | ||
attr, | ||
children, | ||
claim_element, | ||
detach, | ||
init, | ||
insert_hydration, | ||
noop, | ||
safe_not_equal, | ||
svg_element | ||
} from "svelte/internal"; | ||
|
||
function create_fragment(ctx) { | ||
let svg; | ||
let img; | ||
|
||
return { | ||
c() { | ||
svg = svg_element("svg"); | ||
img = svg_element("img"); | ||
this.h(); | ||
}, | ||
l(nodes) { | ||
svg = claim_element(nodes, "svg", {}, 1); | ||
var svg_nodes = children(svg); | ||
img = claim_element(svg_nodes, "img", { alt: true, src: true }, 1); | ||
svg_nodes.forEach(detach); | ||
this.h(); | ||
}, | ||
h() { | ||
attr(img, "alt", "potato"); | ||
attr(img, "src", /*url*/ ctx[0]); | ||
}, | ||
m(target, anchor) { | ||
insert_hydration(target, svg, anchor); | ||
append_hydration(svg, img); | ||
}, | ||
p(ctx, [dirty]) { | ||
if (dirty & /*url*/ 1) { | ||
attr(img, "src", /*url*/ ctx[0]); | ||
} | ||
}, | ||
i: noop, | ||
o: noop, | ||
d(detaching) { | ||
if (detaching) detach(svg); | ||
} | ||
}; | ||
} | ||
|
||
function instance($$self, $$props, $$invalidate) { | ||
let { url } = $$props; | ||
|
||
$$self.$$set = $$props => { | ||
if ('url' in $$props) $$invalidate(0, url = $$props.url); | ||
}; | ||
|
||
return [url]; | ||
} | ||
|
||
class Component extends SvelteComponent { | ||
constructor(options) { | ||
super(); | ||
init(this, options, instance, create_fragment, safe_not_equal, { url: 0 }); | ||
} | ||
} | ||
|
||
export default Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
export let url; | ||
</script> | ||
|
||
<svg> | ||
<img alt="potato" src={url}> | ||
</svg> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this change intended to address? This seems unrelated to the
src
attribute handling mentioned in #6575.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return of
node.ownerDocument
is possibly null.And in the case of Svelte Native returns null at least in this issue #6575.
Therefore it needs to check nullability.