Merge pull request #2776 from CatoTH/Issue2770-pdfmake-bugfix

Bugfix for #2770
This commit is contained in:
Norman Jäckel 2016-12-16 20:32:54 +01:00 committed by GitHub
commit 4ebb8023e3
2 changed files with 13 additions and 2 deletions

View File

@ -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 {

View File

@ -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 = "<ol><li>Test line 1<span>empty span</span></li></ol>",
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);
});
});
});