You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/10/26 09:19:44 UTC

[GitHub] [incubator-echarts] Ghostbird commented on a change in pull request #13469: [5.0] Allow passing of DOM nodes to setContent

Ghostbird commented on a change in pull request #13469:
URL: https://github.com/apache/incubator-echarts/pull/13469#discussion_r511815890



##########
File path: src/component/tooltip/TooltipHTMLContent.ts
##########
@@ -375,20 +375,26 @@ class TooltipHTMLContent {
             return;
         }
 
+        const el = this.el;
+
         if (isString(arrowPosition) && tooltipModel.get('trigger') === 'item'
             && !shouldTooltipConfine(tooltipModel)) {
             content += assembleArrow(tooltipModel.get('backgroundColor'), borderColor, arrowPosition);
         }
-        if (isObject(content)) {
-            if (this.el.children) {
-                for (var child of Array.from(this.el.children)) {
-                    this.el.removeChild(child);
+        if (isString(content)) {
+            el.innerHTML = content == null ? '' : content;
+        }
+        else if (content) {
+            // Clear previous
+            el.innerHTML = '';
+            if (!isArray(content)) {
+                content = [content];
+            }
+            for (let i = 0; i < content.length; i++) {

Review comment:
       Thanks for cleaning this up!
   I'm curious, is a `for` loop with repeated indexing better than a `for … of` loop? I know that it is more memory efficient in compiled languages where arrays are implemented as contiguous areas of memory, but I had no idea the same was true for Javascript.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org