router-link-helper
Advanced tools
Comparing version
@@ -26,4 +26,6 @@ ;(function(root, factory) { | ||
exports['default'] = { | ||
name: 'router-link-test', | ||
// This is your plugin object. It can be exported to be used anywhere. | ||
var RouterLinkHelper = { | ||
name: 'router-link-helper', | ||
functional: true, | ||
@@ -40,3 +42,4 @@ render: function render(h, _ref) { | ||
} | ||
if (process.browser && data.attrs._blank) { | ||
if (typeof window !== 'undefined' && data.attrs._blank) { | ||
var type = (0, _uaParserJs2['default'])(navigator.userAgent).device.type; | ||
@@ -47,10 +50,11 @@ if (!type) type = 'desktop'; | ||
} | ||
delete data.attrs._blank; | ||
} | ||
return h('router-link', data, children); | ||
// console.log(data) | ||
// return {}; | ||
} | ||
}; | ||
exports['default'] = RouterLinkHelper; | ||
return RouterLinkHelper; | ||
})); |
@@ -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);return exports.default={name:"router-link-test",functional:!0,render:function(e,t){var r=t.data,u=t.children;if(process.browser&&r.attrs._blank){var o=(0,n.default)(navigator.userAgent).device.type;o||(o="desktop"),function(e,t){return t.find(function(t){return t===e})}(o,r.attrs._blank)&&(r.attrs.target="_blank")}return e("router-link",r,u)}},RouterLinkHelper}); | ||
!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}); | ||
//# sourceMappingURL=router-link-helper.es5.min.js.map |
import Vue from 'vue' | ||
import parser from 'ua-parser-js' | ||
// This is your plugin object. It can be exported to be used anywhere. | ||
const RouterLinkHelper = { | ||
export default { | ||
name: 'router-link-test', | ||
functional: true, | ||
render (h, { data, children }) { | ||
function isBlank(type, arrayType){ | ||
return arrayType.find(res =>{ | ||
return res === type; | ||
}); | ||
//console.log(test) | ||
} | ||
if(process.browser && data.attrs._blank) { | ||
let type = parser(navigator.userAgent).device.type; | ||
if(!type) type = 'desktop'; | ||
if(isBlank(type, data.attrs._blank)){ | ||
data.attrs['target'] = '_blank'; | ||
} | ||
} | ||
name: 'router-link-helper', | ||
functional: true, | ||
render (h, { data, children }) { | ||
function isBlank(type, arrayType) { | ||
return arrayType.find(res => { | ||
return res === type; | ||
}); | ||
//console.log(test) | ||
} | ||
if (typeof window !== 'undefined' && data.attrs._blank) { | ||
let type = parser(navigator.userAgent).device.type; | ||
if (!type) type = 'desktop'; | ||
if (isBlank(type, data.attrs._blank)) { | ||
data.attrs['target'] = '_blank'; | ||
} | ||
delete data.attrs._blank; | ||
} | ||
return h('router-link', data, children) | ||
// console.log(data) | ||
// return {}; | ||
return h('router-link', data, children) | ||
} | ||
} | ||
}; | ||
export default RouterLinkHelper; |
@@ -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}}exports['default']={name:'router-link-test',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(process.browser&&d.attrs._blank){var f=(0,_uaParserJs2['default'])(navigator.userAgent).device.type;f||(f='desktop'),c(f,d.attrs._blank)&&(d.attrs.target='_blank')}return a('router-link',d,e)}}; | ||
'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; |
{ | ||
"name": "router-link-helper", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"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
210696
0.26%504
0.2%