ソースを参照

Handle the case of a link with null href. (#4883)

Ian Rose 6 年 前
コミット
abd2891e83
1 ファイル変更3 行追加3 行削除
  1. 3 3
      packages/rendermime/src/renderers.ts

+ 3 - 3
packages/rendermime/src/renderers.ts

@@ -613,7 +613,7 @@ namespace Private {
     // Handle anchor elements.
     let anchors = node.getElementsByTagName('a');
     for (let i = 0; i < anchors.length; i++) {
-      let path = anchors[i].href;
+      let path = anchors[i].href || '';
       const isLocal =
         resolver && resolver.isLocal
           ? resolver.isLocal(path)
@@ -703,7 +703,7 @@ namespace Private {
     name: 'src' | 'href',
     resolver: IRenderMime.IResolver
   ): Promise<void> {
-    let source = node.getAttribute(name);
+    let source = node.getAttribute(name) || '';
     const isLocal = resolver.isLocal
       ? resolver.isLocal(source)
       : URLExt.isLocal(source);
@@ -742,7 +742,7 @@ namespace Private {
   ): Promise<void> {
     // Get the link path without the location prepended.
     // (e.g. "./foo.md#Header 1" vs "http://localhost:8888/foo.md#Header 1")
-    let href = anchor.getAttribute('href');
+    let href = anchor.getAttribute('href') || '';
     const isLocal = resolver.isLocal
       ? resolver.isLocal(href)
       : URLExt.isLocal(href);