Просмотр исходного кода

Merge pull request #7003 from lockphase/master

Strip svg icon id from image url in gui
David Catuhe 6 лет назад
Родитель
Сommit
8997fbbe10
2 измененных файлов с 6 добавлено и 3 удалено
  1. 1 1
      dist/preview release/what's new.md
  2. 5 2
      gui/src/2D/controls/image.ts

+ 1 - 1
dist/preview release/what's new.md

@@ -139,7 +139,7 @@
 - Added `Button.delegatePickingToChildren` to let buttons delegate hit testing to embedded controls ([Deltakosh](https://github.com/deltakosh/))
 - Added `Button.delegatePickingToChildren` to let buttons delegate hit testing to embedded controls ([Deltakosh](https://github.com/deltakosh/))
 - Added `Container.maxLayoutCycle` and `Container.logLayoutCycleErrors` to get more control over layout cycles ([Deltakosh](https://github.com/deltakosh/))
 - Added `Container.maxLayoutCycle` and `Container.logLayoutCycleErrors` to get more control over layout cycles ([Deltakosh](https://github.com/deltakosh/))
 - Added `StackPanel.ignoreLayoutWarnings` to disable console warnings when controls with percentage size are added to a StackPanel ([Deltakosh](https://github.com/deltakosh/))
 - Added `StackPanel.ignoreLayoutWarnings` to disable console warnings when controls with percentage size are added to a StackPanel ([Deltakosh](https://github.com/deltakosh/))
-- Added `_getSVGAttribs` functionality for loading multiple svg icons from an external svg file via icon id. Fixed bug for Chrome.([lockphase](https://github.com/lockphase/))
+- Added `_getSVGAttribs` functionality for loading multiple svg icons from an external svg file via icon id. Fixed bug for Chrome. Strip icon id from image url for firefox.([lockphase](https://github.com/lockphase/))
 
 
 ### Particles
 ### Particles
 
 

+ 5 - 2
gui/src/2D/controls/image.ts

@@ -360,7 +360,7 @@ export class Image extends Control {
         this._source = value;
         this._source = value;
 
 
         if (value) {
         if (value) {
-            this._svgCheck(value);
+            value = this._svgCheck(value);
         }
         }
 
 
         this._domImage = document.createElement("img");
         this._domImage = document.createElement("img");
@@ -377,7 +377,7 @@ export class Image extends Control {
     /**
     /**
      * Checks for svg document with icon id present
      * Checks for svg document with icon id present
      */
      */
-    private _svgCheck(value: string) {
+    private _svgCheck(value: string): string {
         if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
         if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
             var svgsrc = value.split('#')[0];
             var svgsrc = value.split('#')[0];
             var elemid = value.split('#')[1];
             var elemid = value.split('#')[1];
@@ -404,6 +404,9 @@ export class Image extends Control {
                     }
                     }
                 };
                 };
             }
             }
+            return svgsrc;
+        } else {
+            return value;
         }
         }
     }
     }