PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/shortcode/index.js +50 -46 12.6.0 → 14.5.2 View file →
@@ -1,9 +1,9 @@
1 -/******/ (function() { // webpackBootstrap
1 +/******/ (() => { // webpackBootstrap
2 2 /******/ var __webpack_modules__ = ({
3 3
4 -/***/ 9588:
5 -/***/ (function(module) {
4 +/***/ 9756:
5 +/***/ ((module) => {
6 6
7 7 /**
8 8 * Memize options object.
9 9 *
@@ -196,23 +196,23 @@
196 196 /******/ }
197 197 /******/
198 198 /************************************************************************/
199 199 /******/ /* webpack/runtime/compat get default export */
200 -/******/ !function() {
200 +/******/ (() => {
201 201 /******/ // getDefaultExport function for compatibility with non-harmony modules
202 -/******/ __webpack_require__.n = function(module) {
202 +/******/ __webpack_require__.n = (module) => {
203 203 /******/ var getter = module && module.__esModule ?
204 -/******/ function() { return module['default']; } :
205 -/******/ function() { return module; };
204 +/******/ () => (module['default']) :
205 +/******/ () => (module);
206 206 /******/ __webpack_require__.d(getter, { a: getter });
207 207 /******/ return getter;
208 208 /******/ };
209 -/******/ }();
209 +/******/ })();
210 210 /******/
211 211 /******/ /* webpack/runtime/define property getters */
212 -/******/ !function() {
212 +/******/ (() => {
213 213 /******/ // define getter functions for harmony exports
214 -/******/ __webpack_require__.d = function(exports, definition) {
214 +/******/ __webpack_require__.d = (exports, definition) => {
215 215 /******/ for(var key in definition) {
216 216 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
217 217 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
218 218 /******/ }
@@ -217,39 +217,30 @@
217 217 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
218 218 /******/ }
219 219 /******/ }
220 220 /******/ };
221 -/******/ }();
221 +/******/ })();
222 222 /******/
223 223 /******/ /* webpack/runtime/hasOwnProperty shorthand */
224 -/******/ !function() {
225 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
226 -/******/ }();
224 +/******/ (() => {
225 +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
226 +/******/ })();
227 227 /******/
228 228 /************************************************************************/
229 229 var __webpack_exports__ = {};
230 230 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
231 -!function() {
231 +(() => {
232 232 "use strict";
233 -
234 -// EXPORTS
235 -__webpack_require__.d(__webpack_exports__, {
236 - "default": function() { return /* binding */ build_module; }
237 -});
238 -
239 -// UNUSED EXPORTS: attrs, fromMatch, next, regexp, replace, string
240 -
241 -;// CONCATENATED MODULE: external "lodash"
242 -var external_lodash_namespaceObject = window["lodash"];
243 -// EXTERNAL MODULE: ./node_modules/memize/index.js
244 -var memize = __webpack_require__(9588);
245 -var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
246 -;// CONCATENATED MODULE: ./packages/shortcode/build-module/index.js
233 +/* harmony export */ __webpack_require__.d(__webpack_exports__, {
234 +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
235 +/* harmony export */ });
236 +/* unused harmony exports next, replace, string, regexp, attrs, fromMatch */
237 +/* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9756);
238 +/* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_0__);
247 239 /**
248 240 * External dependencies
249 241 */
250 242
251 -
252 243 /**
253 244 * Shortcode attributes object.
254 245 *
255 246 * @typedef {Object} WPShortcodeAttrs
@@ -406,9 +397,9 @@
406 397 *
407 398 * @return {WPShortcodeAttrs} Parsed shortcode attributes.
408 399 */
409 400
410 -const attrs = memize_default()(text => {
401 +const attrs = memize__WEBPACK_IMPORTED_MODULE_0___default()(text => {
411 402 const named = {};
412 403 const numeric = []; // This regular expression is reused from `shortcode_parse_atts()` in
413 404 // `wp-includes/shortcodes.php`.
414 405 //
@@ -492,11 +483,20 @@
492 483 *
493 484 * @return {WPShortcode} Shortcode instance.
494 485 */
495 486
496 -const shortcode = (0,external_lodash_namespaceObject.extend)(function (options) {
497 - (0,external_lodash_namespaceObject.extend)(this, (0,external_lodash_namespaceObject.pick)(options || {}, 'tag', 'attrs', 'type', 'content'));
498 - const attributes = this.attrs; // Ensure we have a correctly formatted `attrs` object.
487 +const shortcode = Object.assign(function (options) {
488 + const {
489 + tag,
490 + attrs: attributes,
491 + type,
492 + content
493 + } = options || {};
494 + Object.assign(this, {
495 + tag,
496 + type,
497 + content
498 + }); // Ensure we have a correctly formatted `attrs` object.
499 499
500 500 this.attrs = {
501 501 named: {},
502 502 numeric: []
@@ -503,17 +503,19 @@
503 503 };
504 504
505 505 if (!attributes) {
506 506 return;
507 - } // Parse a string of attributes.
507 + }
508 508
509 + const attributeTypes = ['named', 'numeric']; // Parse a string of attributes.
509 510
510 - if ((0,external_lodash_namespaceObject.isString)(attributes)) {
511 + if (typeof attributes === 'string') {
511 512 this.attrs = attrs(attributes); // Identify a correctly formatted `attrs` object.
512 - } else if ((0,external_lodash_namespaceObject.isEqual)(Object.keys(attributes), ['named', 'numeric'])) {
513 + } else if (attributes.length === attributeTypes.length && attributeTypes.every((t, key) => t === attributes[key])) {
513 514 this.attrs = attributes; // Handle a flat object of attributes.
514 515 } else {
515 - (0,external_lodash_namespaceObject.forEach)(attributes, (value, key) => {
516 + Object.entries(attributes).forEach(_ref => {
517 + let [key, value] = _ref;
516 518 this.set(key, value);
517 519 });
518 520 }
519 521 }, {
@@ -523,9 +525,9 @@
523 525 regexp,
524 526 attrs,
525 527 fromMatch
526 528 });
527 -(0,external_lodash_namespaceObject.extend)(shortcode.prototype, {
529 +Object.assign(shortcode.prototype, {
528 530 /**
529 531 * Get a shortcode attribute.
530 532 *
531 533 * Automatically detects whether `attr` is named or numeric and routes it
@@ -535,9 +537,9 @@
535 537 *
536 538 * @return {string} Attribute value.
537 539 */
538 540 get(attr) {
539 - return this.attrs[(0,external_lodash_namespaceObject.isNumber)(attr) ? 'numeric' : 'named'][attr];
541 + return this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr];
540 542 },
541 543
542 544 /**
543 545 * Set a shortcode attribute.
@@ -550,9 +552,9 @@
550 552 *
551 553 * @return {WPShortcode} Shortcode instance.
552 554 */
553 555 set(attr, value) {
554 - this.attrs[(0,external_lodash_namespaceObject.isNumber)(attr) ? 'numeric' : 'named'][attr] = value;
556 + this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr] = value;
555 557 return this;
556 558 },
557 559
558 560 /**
@@ -561,9 +563,9 @@
561 563 * @return {string} String representation of the shortcode.
562 564 */
563 565 string() {
564 566 let text = '[' + this.tag;
565 - (0,external_lodash_namespaceObject.forEach)(this.attrs.numeric, value => {
567 + this.attrs.numeric.forEach(value => {
566 568 if (/\s/.test(value)) {
567 569 text += ' "' + value + '"';
568 570 } else {
569 571 text += ' ' + value;
@@ -568,9 +570,10 @@
568 570 } else {
569 571 text += ' ' + value;
570 572 }
571 573 });
572 - (0,external_lodash_namespaceObject.forEach)(this.attrs.named, (value, name) => {
574 + Object.entries(this.attrs.named).forEach(_ref2 => {
575 + let [name, value] = _ref2;
573 576 text += ' ' + name + '="' + value + '"';
574 577 }); // If the tag is marked as `single` or `self-closing`, close the tag and
575 578 // ignore any additional content.
576 579
@@ -591,10 +594,11 @@
591 594 return text + '[/' + this.tag + ']';
592 595 }
593 596
594 597 });
595 -/* harmony default export */ var build_module = (shortcode);
596 -//# sourceMappingURL=index.js.map
597 -}();
598 +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (shortcode);
599 +
600 +})();
601 +
598 602 (window.wp = window.wp || {}).shortcode = __webpack_exports__["default"];
599 603 /******/ })()
600 604 ;