fix(Svg): cancel stale fetch in set_url so leaf nodes hide arrow (race condition)
This commit is contained in:
parent
7746595739
commit
ee50245895
@ -23,6 +23,8 @@ bricks.Svg = class extends bricks.VBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_url(url){
|
set_url(url){
|
||||||
|
this._url_token = (this._url_token || 0) + 1;
|
||||||
|
var token = this._url_token;
|
||||||
if (!url){
|
if (!url){
|
||||||
this.dom_element.innerHTML = '';
|
this.dom_element.innerHTML = '';
|
||||||
return;
|
return;
|
||||||
@ -31,6 +33,7 @@ bricks.Svg = class extends bricks.VBox {
|
|||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(svgText => {
|
.then(svgText => {
|
||||||
|
if (token !== this._url_token) return;
|
||||||
if (svgText.startsWith("<svg ")){
|
if (svgText.startsWith("<svg ")){
|
||||||
this.svgText = svgText;
|
this.svgText = svgText;
|
||||||
this.set_colored_svg(this.color);
|
this.set_colored_svg(this.color);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user