MCPcopy
hub / github.com/kangax/html-minifier / parseEndTag

Function parseEndTag

src/htmlparser.js:395–432  ·  view source on GitHub ↗
(tag, tagName)

Source from the content-addressed store, hash-verified

393 }
394
395 function parseEndTag(tag, tagName) {
396 var pos;
397
398 // Find the closest opened tag of the same type
399 if (tagName) {
400 pos = findTag(tagName);
401 }
402 // If no tag name is provided, clean shop
403 else {
404 pos = 0;
405 }
406
407 if (pos >= 0) {
408 // Close all the open elements, up the stack
409 for (var i = stack.length - 1; i >= pos; i--) {
410 if (handler.end) {
411 handler.end(stack[i].tag, stack[i].attrs, i > pos || !tag);
412 }
413 }
414
415 // Remove the open elements from the stack
416 stack.length = pos;
417 lastTag = pos && stack[pos - 1].tag;
418 }
419 else if (tagName.toLowerCase() === 'br') {
420 if (handler.start) {
421 handler.start(tagName, [], true, '');
422 }
423 }
424 else if (tagName.toLowerCase() === 'p') {
425 if (handler.start) {
426 handler.start(tagName, [], false, '', true);
427 }
428 if (handler.end) {
429 handler.end(tagName, []);
430 }
431 }
432 }
433}
434
435exports.HTMLParser = HTMLParser;

Callers 3

HTMLParserFunction · 0.85
closeIfFoundFunction · 0.85
handleStartTagFunction · 0.85

Calls 1

findTagFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…