gatsby-link 2.4.5 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/index.js +52 -55
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.4.6](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.5...gatsby-link@2.4.6) (2020-06-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package gatsby-link
|
|
9
|
+
|
|
6
10
|
## [2.4.5](https://github.com/gatsbyjs/gatsby/compare/gatsby-link@2.4.4...gatsby-link@2.4.5) (2020-06-03)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/index.js
CHANGED
|
@@ -15,8 +15,6 @@ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
15
15
|
|
|
16
16
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
17
17
|
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
21
19
|
|
|
22
20
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -113,7 +111,7 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
|
|
|
113
111
|
|
|
114
112
|
_this = _React$Component.call(this, props) || this; // Default to no support for IntersectionObserver
|
|
115
113
|
|
|
116
|
-
|
|
114
|
+
_this.defaultGetProps = function (_ref2) {
|
|
117
115
|
var isPartiallyCurrent = _ref2.isPartiallyCurrent,
|
|
118
116
|
isCurrent = _ref2.isCurrent;
|
|
119
117
|
|
|
@@ -125,7 +123,8 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
|
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
return null;
|
|
128
|
-
}
|
|
126
|
+
};
|
|
127
|
+
|
|
129
128
|
var IOSupported = false;
|
|
130
129
|
|
|
131
130
|
if (typeof window !== "undefined" && window.IntersectionObserver) {
|
|
@@ -205,54 +204,53 @@ var GatsbyLink = /*#__PURE__*/function (_React$Component) {
|
|
|
205
204
|
console.warn("External link " + to + " was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links");
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (e.button === 0 && // ignore right clicks
|
|
229
|
-
!_this3.props.target && // let browser handle "target=_blank"
|
|
230
|
-
!e.defaultPrevented && // onClick prevented default
|
|
231
|
-
!e.metaKey && // ignore clicks with modifier keys...
|
|
232
|
-
!e.altKey && !e.ctrlKey && !e.shiftKey) {
|
|
233
|
-
e.preventDefault();
|
|
234
|
-
var shouldReplace = replace;
|
|
235
|
-
var isCurrent = encodeURI(prefixedTo) === window.location.pathname;
|
|
236
|
-
|
|
237
|
-
if (typeof replace !== "boolean" && isCurrent) {
|
|
238
|
-
shouldReplace = true;
|
|
239
|
-
} // Make sure the necessary scripts and data are
|
|
240
|
-
// loaded before continuing.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
window.___navigate(prefixedTo, {
|
|
244
|
-
state: state,
|
|
245
|
-
replace: shouldReplace
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return true;
|
|
207
|
+
return /*#__PURE__*/_react.default.createElement(_router.Location, null, function (_ref3) {
|
|
208
|
+
var location = _ref3.location;
|
|
209
|
+
var prefixedTo = rewriteLinkPath(to, location.pathname);
|
|
210
|
+
return isLocalLink(prefixedTo) ? /*#__PURE__*/_react.default.createElement(_router.Link, (0, _extends2.default)({
|
|
211
|
+
to: prefixedTo,
|
|
212
|
+
state: state,
|
|
213
|
+
getProps: getProps,
|
|
214
|
+
innerRef: _this3.handleRef,
|
|
215
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
216
|
+
if (_onMouseEnter) {
|
|
217
|
+
_onMouseEnter(e);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
___loader.hovering((0, _parsePath.parsePath)(prefixedTo).pathname);
|
|
221
|
+
},
|
|
222
|
+
onClick: function onClick(e) {
|
|
223
|
+
if (_onClick) {
|
|
224
|
+
_onClick(e);
|
|
250
225
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
226
|
+
|
|
227
|
+
if (e.button === 0 && // ignore right clicks
|
|
228
|
+
!_this3.props.target && // let browser handle "target=_blank"
|
|
229
|
+
!e.defaultPrevented && // onClick prevented default
|
|
230
|
+
!e.metaKey && // ignore clicks with modifier keys...
|
|
231
|
+
!e.altKey && !e.ctrlKey && !e.shiftKey) {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
var shouldReplace = replace;
|
|
234
|
+
var isCurrent = encodeURI(prefixedTo) === window.location.pathname;
|
|
235
|
+
|
|
236
|
+
if (typeof replace !== "boolean" && isCurrent) {
|
|
237
|
+
shouldReplace = true;
|
|
238
|
+
} // Make sure the necessary scripts and data are
|
|
239
|
+
// loaded before continuing.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
window.___navigate(prefixedTo, {
|
|
243
|
+
state: state,
|
|
244
|
+
replace: shouldReplace
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
}, rest)) : /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
|
|
251
|
+
href: prefixedTo
|
|
252
|
+
}, rest));
|
|
253
|
+
});
|
|
256
254
|
};
|
|
257
255
|
|
|
258
256
|
return GatsbyLink;
|
|
@@ -270,10 +268,9 @@ var showDeprecationWarning = function showDeprecationWarning(functionName, altFu
|
|
|
270
268
|
};
|
|
271
269
|
|
|
272
270
|
var _default = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
);
|
|
271
|
+
return /*#__PURE__*/_react.default.createElement(GatsbyLink, (0, _extends2.default)({
|
|
272
|
+
innerRef: ref
|
|
273
|
+
}, props));
|
|
277
274
|
});
|
|
278
275
|
|
|
279
276
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-link",
|
|
3
3
|
"description": "An enhanced Link component for Gatsby sites with support for resource prefetching",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.6",
|
|
5
5
|
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/gatsbyjs/gatsby/issues"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@babel/cli": "^7.10.1",
|
|
16
16
|
"@babel/core": "^7.10.2",
|
|
17
17
|
"@testing-library/react": "^9.5.0",
|
|
18
|
-
"babel-preset-gatsby-package": "^0.4.
|
|
18
|
+
"babel-preset-gatsby-package": "^0.4.4",
|
|
19
19
|
"cross-env": "^5.2.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=10.13.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "221481bef7733c9957fb9ba83178f08280243b81"
|
|
47
47
|
}
|