]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Detect bold font was broken correctly.
authoryutaka <shigure@refy.net>
Wed, 8 Mar 2017 01:03:18 +0000 (01:03 +0000)
committeryutaka <shigure@refy.net>
Wed, 8 Mar 2017 04:54:18 +0000 (04:54 +0000)
src/Renderer.ts

index 9b6234caf2b46242c1b5db870e022efcecdb3d50..e1ebbe8f09ed0298ed02865ebfbe20f6c9451fc7 100644 (file)
@@ -34,7 +34,7 @@ export class Renderer {
     // Figure out whether boldness affects
     // the character width of monospace fonts.
     if (brokenBold === null) {
-      brokenBold = checkBoldBroken((<any>this._terminal).document);
+      brokenBold = checkBoldBroken((<any>this._terminal).element);
     }
 
     // TODO: Pull more DOM interactions into Renderer.constructor, element for
@@ -291,14 +291,14 @@ export class Renderer {
 
 // if bold is broken, we can't
 // use it in the terminal.
-function checkBoldBroken(document) {
-  const body = document.getElementsByTagName('body')[0];
+function checkBoldBroken(terminal) {
+  const document = terminal.ownerDocument;
   const el = document.createElement('span');
   el.innerHTML = 'hello world';
-  body.appendChild(el);
+  terminal.appendChild(el);
   const w1 = el.scrollWidth;
   el.style.fontWeight = 'bold';
   const w2 = el.scrollWidth;
-  body.removeChild(el);
+  terminal.removeChild(el);
   return w1 !== w2;
 }