Revision | ecfda231c93a5d24f1477316fe687d05eae8445e (tree) |
---|---|
Zeit | 2019-08-16 02:48:47 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2490 search2 plugin: Only li element allowed as ul child
@@ -352,10 +352,10 @@ EOD; | ||
352 | 352 | <p>$_msg_unsupported_webbrowser $alt_msg</p> |
353 | 353 | </noscript> |
354 | 354 | <style> |
355 | -input#_plugin_search2_detail:checked ~ ul > div.search-result-detail { | |
355 | +input#_plugin_search2_detail:checked ~ ul > li > div.search-result-detail { | |
356 | 356 | display:block; |
357 | 357 | } |
358 | -input#_plugin_search2_detail ~ ul > div.search-result-detail { | |
358 | +input#_plugin_search2_detail ~ ul > li > div.search-result-detail { | |
359 | 359 | display:none; |
360 | 360 | } |
361 | 361 | ._plugin_search2_search_status { |
@@ -654,15 +654,14 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
654 | 654 | * @param {Array<Object>} results |
655 | 655 | * @param {string} searchText |
656 | 656 | * @param {RegExp} searchRegex |
657 | - * @param {Element} parentElement | |
657 | + * @param {Element} parentUlElement | |
658 | 658 | * @param {boolean} insertTop |
659 | 659 | */ |
660 | - function addSearchResult(results, searchText, searchRegex, parentElement, insertTop) { | |
660 | + function addSearchResult(results, searchText, searchRegex, parentUlElement, insertTop) { | |
661 | 661 | var props = getSiteProps(); |
662 | 662 | var now = new Date(); |
663 | 663 | var parentFragment = document.createDocumentFragment(); |
664 | 664 | results.forEach(function(val) { |
665 | - var fragment = document.createDocumentFragment(); | |
666 | 665 | var li = document.createElement('li'); |
667 | 666 | var hash = '#q=' + encodeSearchTextForHash(searchText); |
668 | 667 | var href = val.url + hash; |
@@ -679,7 +678,7 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
679 | 678 | decoratedName + '</a>' + passageHtml; |
680 | 679 | li.innerHTML = liHtml; |
681 | 680 | li.setAttribute('data-pagename', val.name); |
682 | - fragment.appendChild(li); | |
681 | + // Page detail div | |
683 | 682 | var div = document.createElement('div'); |
684 | 683 | div.classList.add('search-result-detail'); |
685 | 684 | var head = document.createElement('div'); |
@@ -693,13 +692,14 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
693 | 692 | div.appendChild(pre); |
694 | 693 | } |
695 | 694 | div.setAttribute('data-pagename', val.name); |
696 | - fragment.appendChild(div); | |
697 | - parentFragment.appendChild(fragment); | |
695 | + // Add li to ul (parentUlElement) | |
696 | + li.appendChild(div); | |
697 | + parentFragment.appendChild(li); | |
698 | 698 | }); |
699 | - if (insertTop && parentElement.firstChild) { | |
700 | - parentElement.insertBefore(parentFragment, parentElement.firstChild); | |
699 | + if (insertTop && parentUlElement.firstChild) { | |
700 | + parentUlElement.insertBefore(parentFragment, parentUlElement.firstChild); | |
701 | 701 | } else { |
702 | - parentElement.appendChild(parentFragment); | |
702 | + parentUlElement.appendChild(parentFragment); | |
703 | 703 | } |
704 | 704 | } |
705 | 705 | function removeCachedResultsBase(keepTodayCache) { |