wp/wp-includes/blocks/query/view.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    52 /******/ 	__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
    52 /******/ 	__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
    53 /******/ })();
    53 /******/ })();
    54 /******/ 
    54 /******/ 
    55 /************************************************************************/
    55 /************************************************************************/
    56 var __webpack_exports__ = {};
    56 var __webpack_exports__ = {};
    57 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
       
    58 (() => {
       
    59 
    57 
    60 ;// CONCATENATED MODULE: external "@wordpress/interactivity"
    58 ;// external "@wordpress/interactivity"
    61 var x = (y) => {
    59 var x = (y) => {
    62 	var x = {}; __webpack_require__.d(x, y); return x
    60 	var x = {}; __webpack_require__.d(x, y); return x
    63 } 
    61 } 
    64 var y = (x) => (() => (x))
    62 var y = (x) => (() => (x))
    65 const interactivity_namespaceObject = x({ ["getContext"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), ["getElement"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), ["store"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });
    63 const interactivity_namespaceObject = x({ ["getContext"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getContext), ["getElement"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getElement), ["store"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store), ["withSyncEvent"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.withSyncEvent) });
    66 ;// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/query/view.js
    64 ;// ./node_modules/@wordpress/block-library/build-module/query/view.js
    67 /**
    65 /**
    68  * WordPress dependencies
    66  * WordPress dependencies
    69  */
    67  */
    70 
    68 
    71 const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
    69 const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
    78 !event.altKey &&
    76 !event.altKey &&
    79 // Download.
    77 // Download.
    80 !event.shiftKey && !event.defaultPrevented;
    78 !event.shiftKey && !event.defaultPrevented;
    81 (0,interactivity_namespaceObject.store)('core/query', {
    79 (0,interactivity_namespaceObject.store)('core/query', {
    82   actions: {
    80   actions: {
    83     *navigate(event) {
    81     navigate: (0,interactivity_namespaceObject.withSyncEvent)(function* (event) {
    84       const ctx = (0,interactivity_namespaceObject.getContext)();
    82       const ctx = (0,interactivity_namespaceObject.getContext)();
    85       const {
    83       const {
    86         ref
    84         ref
    87       } = (0,interactivity_namespaceObject.getElement)();
    85       } = (0,interactivity_namespaceObject.getElement)();
    88       const queryRef = ref.closest('.wp-block-query[data-wp-router-region]');
    86       const queryRef = ref.closest('.wp-block-query[data-wp-router-region]');
    96 
    94 
    97         // Focus the first anchor of the Query block.
    95         // Focus the first anchor of the Query block.
    98         const firstAnchor = `.wp-block-post-template a[href]`;
    96         const firstAnchor = `.wp-block-post-template a[href]`;
    99         queryRef.querySelector(firstAnchor)?.focus();
    97         queryRef.querySelector(firstAnchor)?.focus();
   100       }
    98       }
   101     },
    99     }),
   102     *prefetch() {
   100     *prefetch() {
   103       const {
   101       const {
   104         ref
   102         ref
   105       } = (0,interactivity_namespaceObject.getElement)();
   103       } = (0,interactivity_namespaceObject.getElement)();
   106       if (isValidLink(ref)) {
   104       if (isValidLink(ref)) {
   129   }
   127   }
   130 }, {
   128 }, {
   131   lock: true
   129   lock: true
   132 });
   130 });
   133 
   131 
   134 })();
       
   135