Skip to content
  • Oliver Hader's avatar
    [TASK] Avoid inline JavaScript generated by BackendUtility:viewOnClick · f16b4787
    Oliver Hader authored and Benni Mack's avatar Benni Mack committed
    
    
    Inline JavaScript produced by BackendUtility:viewOnClick is substituted
    with markup based instructions and static JavaScript event handlers.
    
    // basically delivers window.open(generatedUri)
    BackendUtility::viewOnClick($pageId, $backPath, $rootLine, $section,
        $viewUri, $getVars, $switchFocus);
    
    can be substituted with e.g.
    
    \TYPO3\CMS\Backend\Routing\PreviewUriBuilder::create($pageId, $viewUri)
        ->withRootLine($rootLine)
        ->withSection($section)
        ->withAdditionalQueryParameters($getVars)
        ->serializeDispatcherAttributes([
            PreviewUriBuilder::OPTION_SWITCH_FOCUS => $switchFocus,
        ]);
    
    which results in the following HTML data attributes
    (data can be retrieved as array of complete element as well)
    
    data-dispatch-action="TYPO3.WindowManager.localOpen"
    data-dispatch-args="["https://...",null,"previewWin"]"
    
    Resolves: #91123
    Releases: master
    Change-Id: Iedd9bfe60827977677ee68e2c948c63e359abf84
    Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64243
    Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
    Tested-by: default avatarTYPO3com <noreply@typo3.com>
    Tested-by: default avatarBenni Mack <benni@typo3.org>
    Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
    Reviewed-by: default avatarBenni Mack <benni@typo3.org>
    f16b4787