Postpone find() until it is needed

This is a fix for issue #917.

It seems that 'symbols' was originally included as a performance optimization, to avoid repeated find() calls for '.jasmine-symbol-summary'. However this find() occasionally fails during initialize if the dom has not loaded completely.

This change will not affect performance, as symbols is still cached. However it improves upon the original code in that the find happens at a stage much later than initialize.
This commit is contained in:
danielalexiuc
2015-09-16 11:52:05 +10:00
parent 4097718b66
commit c017f0000d

View File

@@ -36,8 +36,6 @@ jasmineRequire.HtmlReporter = function(j$) {
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find('.jasmine-symbol-summary');
};
var totalSpecsDefined;
@@ -82,6 +80,10 @@ jasmineRequire.HtmlReporter = function(j$) {
specsExecuted++;
}
if (!symbols){
symbols = find('.jasmine-symbol-summary');
}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
id: 'spec_' + result.id,