router-link-helper
Advanced tools
Comparing version 0.1.0 to 0.1.2
@@ -30,6 +30,8 @@ ;(function(root, factory) { | ||
name: 'router-link-helper', | ||
props: ['_blank'], | ||
functional: true, | ||
render: function render(h, _ref) { | ||
var data = _ref.data, | ||
children = _ref.children; | ||
children = _ref.children, | ||
props = _ref.props; | ||
@@ -43,11 +45,12 @@ function isBlank(type, arrayType) { | ||
if (typeof window !== 'undefined' && data.attrs._blank) { | ||
if (typeof window !== 'undefined' && props._blank) { | ||
var type = (0, _uaParserJs2['default'])(navigator.userAgent).device.type; | ||
if (!type) type = 'desktop'; | ||
if (isBlank(type, data.attrs._blank)) { | ||
if (isBlank(type, props._blank)) { | ||
data.attrs['target'] = '_blank'; | ||
} | ||
delete data.attrs._blank; | ||
} | ||
//delete data.attrs._blank; | ||
return h('router-link', data, children); | ||
@@ -54,0 +57,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.RouterLinkHelper=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("vue"),r=(e(t),require("ua-parser-js")),n=e(r),u={name:"router-link-helper",functional:!0,render:function(e,t){var r=t.data,u=t.children;if("undefined"!=typeof window&&r.attrs._blank){var i=(0,n.default)(navigator.userAgent).device.type;i||(i="desktop"),function(e,t){return t.find(function(t){return t===e})}(i,r.attrs._blank)&&(r.attrs.target="_blank"),delete r.attrs._blank}return e("router-link",r,u)}};return exports.default=u,u}); | ||
!function(e,r){"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?module.exports=r():e.RouterLinkHelper=r()}(this,function(){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("vue"),n=(e(r),require("ua-parser-js")),t=e(n),u={name:"router-link-helper",props:["_blank"],functional:!0,render:function(e,r){var n=r.data,u=r.children,o=r.props;if("undefined"!=typeof window&&o._blank){var i=(0,t.default)(navigator.userAgent).device.type;i||(i="desktop"),function(e,r){return r.find(function(r){return r===e})}(i,o._blank)&&(n.attrs.target="_blank")}return e("router-link",n,u)}};return exports.default=u,u}); | ||
//# sourceMappingURL=router-link-helper.es5.min.js.map |
@@ -7,4 +7,5 @@ import Vue from 'vue' | ||
name: 'router-link-helper', | ||
props:['_blank'], | ||
functional: true, | ||
render (h, { data, children }) { | ||
render (h, { data, children, props }) { | ||
function isBlank(type, arrayType) { | ||
@@ -17,11 +18,13 @@ return arrayType.find(res => { | ||
if (typeof window !== 'undefined' && data.attrs._blank) { | ||
if (typeof window !== 'undefined' && props._blank) { | ||
let type = parser(navigator.userAgent).device.type; | ||
if (!type) type = 'desktop'; | ||
if (isBlank(type, data.attrs._blank)) { | ||
if (isBlank(type, props._blank)) { | ||
data.attrs['target'] = '_blank'; | ||
} | ||
delete data.attrs._blank; | ||
} | ||
//delete data.attrs._blank; | ||
return h('router-link', data, children) | ||
@@ -28,0 +31,0 @@ } |
@@ -1,1 +0,1 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _vue=require('vue'),_vue2=_interopRequireDefault(_vue),_uaParserJs=require('ua-parser-js'),_uaParserJs2=_interopRequireDefault(_uaParserJs);function _interopRequireDefault(a){return a&&a.__esModule?a:{'default':a}}var RouterLinkHelper={name:'router-link-helper',functional:!0,render:function render(a,b){function c(f,g){return g.find(function(i){return i===f})}var d=b.data,e=b.children;if('undefined'!=typeof window&&d.attrs._blank){var f=(0,_uaParserJs2['default'])(navigator.userAgent).device.type;f||(f='desktop'),c(f,d.attrs._blank)&&(d.attrs.target='_blank'),delete d.attrs._blank}return a('router-link',d,e)}};exports['default']=RouterLinkHelper; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _vue=require('vue'),_vue2=_interopRequireDefault(_vue),_uaParserJs=require('ua-parser-js'),_uaParserJs2=_interopRequireDefault(_uaParserJs);function _interopRequireDefault(a){return a&&a.__esModule?a:{'default':a}}var RouterLinkHelper={name:'router-link-helper',props:['_blank'],functional:!0,render:function render(a,b){function c(g,i){return i.find(function(j){return j===g})}var d=b.data,e=b.children,f=b.props;if('undefined'!=typeof window&&f._blank){var g=(0,_uaParserJs2['default'])(navigator.userAgent).device.type;g||(g='desktop'),c(g,f._blank)&&(d.attrs.target='_blank')}return a('router-link',d,e)}};exports['default']=RouterLinkHelper; |
{ | ||
"name": "router-link-helper", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "vue router-link helper", | ||
@@ -5,0 +5,0 @@ "main": "dist/router-link-helper.es5.js", |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3
206141
28
503