andrewrk / swig-email-templates

Node.js module for rendering emails with swig templates and email-friendly inline CSS using boost.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

document.parentWindow.close() throws error

geNAZt opened this issue · comments

If i try to use the this module to compile Templates i get this error:

TypeError: Object object has no method 'close'
at F:\Projekte\git-dash\node_modules\swig-email-templates\index.js:53:37
at inlineDocumentWithCb (F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\lib\juice.js:205:5)
at F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\lib\juice.js:129:5
at F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\lib\juice.js:285:5
at F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\node_modules\batch\lib\batch.js:85:20
at getStylesData (F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\lib\juice.js:226:3)
at F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\lib\juice.js:272:35
at F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\node_modules\batch\lib\batch.js:65:5
at Array.forEach (native)
at Batch.end (F:\Projekte\git-dash\node_modules\swig-email-templates\node_modules\juice\node_modules\batch\lib\batch.js:63:12)

If i replace L44 - 55 of the index.js

            if (err) {
              // free the associated memory
              // with lazily created parentWindow
              try {
                document.parentWindow.close();
              } catch (cleanupErr) {}
              cb(err);
            } else {
              var inner = document.innerHTML;
              document.parentWindow.close();
              cb(null, inner);
            }

with

            if (err) {
              // free the associated memory
              // with lazily created parentWindow
              try {
                document.close();
              } catch (cleanupErr) {}
              cb(err);
            } else {
              var inner = document.innerHTML;
              document.close();
              cb(null, inner);
            }

It works

hmm. do the tests of this module pass for you?

no matter. I pushed a fix which should solve it either way.