diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js index c56ee5be2..f4980aefe 100644 --- a/openslides/core/static/js/core/pdf.js +++ b/openslides/core/static/js/core/pdf.js @@ -410,7 +410,7 @@ angular.module('OpenSlidesApp.core.pdf', []) */ extractLineNumbers = function(element) { var foundLineNumbers = []; - if (element.nodeName == 'SPAN' && element.getAttribute('class').indexOf('os-line-number') > -1) { + if (element.nodeName == 'SPAN' && element.getAttribute('class') && element.getAttribute('class').indexOf('os-line-number') > -1) { foundLineNumbers.push(element.getAttribute('data-line-number')); element.parentNode.removeChild(element); } else { diff --git a/tests/karma/core/pdf.service.test.js b/tests/karma/core/pdf.service.test.js index 2b4807257..c97671b80 100644 --- a/tests/karma/core/pdf.service.test.js +++ b/tests/karma/core/pdf.service.test.js @@ -158,6 +158,17 @@ describe('pdf', function () { "margin": [0,10,0,0] })); expect(JSON.stringify(pdfmake[2])).toBe(emptyline); - }) + }); + + it('does not break with non-line-break SPANs', function () { + var inHtml = "
  1. Test line 1empty span
", + numberedHtml = lineNumberingService.insertLineNumbers(inHtml, 80); + + var instance = PdfMakeConverter.createInstance(); + var pdfmake = instance.convertHTML(numberedHtml, 'outside'); + + // the actual result is's the point here; only that it doesn't throw an exception + expect(JSON.stringify(pdfmake[0])).toBe(emptyline); + }); }); }); \ No newline at end of file