@fortawesome/vue-fontawesome 2.0.2 → 2.0.3

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 CHANGED
@@ -10,6 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
10
10
 
11
11
  ---
12
12
 
13
+ ## [2.0.3](https://github.com/FortAwesome/vue-fontawesome/releases/tag/2.0.3) - 2021-10-15
14
+
15
+ ### Fixed
16
+ * Skip parse.icon if the icon is imported directly from an icon package
17
+
18
+ ---
19
+
13
20
  ## [2.0.2](https://github.com/FortAwesome/vue-fontawesome/releases/tag/2.0.2) - 2020-12-17
14
21
 
15
22
  ### Fixed
package/README.md CHANGED
@@ -21,7 +21,6 @@
21
21
  <!-- toc -->
22
22
 
23
23
  - [Introduction](#introduction)
24
- * [CodeSandbox Starter Sample 🚀](#codesandbox-starter-sample-%F0%9F%9A%80)
25
24
  * [Upgrading Font Awesome?](#upgrading-font-awesome)
26
25
  * [Get started](#get-started)
27
26
  * [Learn about our new SVG implementation](#learn-about-our-new-svg-implementation)
@@ -69,10 +68,6 @@
69
68
 
70
69
  Hey there! We're glad you're here...
71
70
 
72
- ### CodeSandbox Starter Sample 🚀
73
-
74
- Here's a [CodeSandbox Starter Sample](https://codesandbox.io/s/github/FortAwesome/vue-fontawesome/tree/master/examples/vue-cli-webpack) on how to display Solid, Regular, and Brand icons [using the Icon Library](https://github.com/FortAwesome/vue-fontawesome#usage).
75
-
76
71
  ### Upgrading Font Awesome?
77
72
 
78
73
  If you've used Font Awesome in the past (version 4 or older) there are some
package/index.es.js CHANGED
@@ -328,6 +328,12 @@ function addStaticClass(to, what) {
328
328
  }
329
329
 
330
330
  function normalizeIconArgs(icon$$1) {
331
+ // this has everything that it needs to be rendered which means it was probably imported
332
+ // directly from an icon svg package
333
+ if (icon$$1 && (typeof icon$$1 === 'undefined' ? 'undefined' : _typeof(icon$$1)) === 'object' && icon$$1.prefix && icon$$1.iconName && icon$$1.icon) {
334
+ return icon$$1;
335
+ }
336
+
331
337
  if (parse.icon) {
332
338
  return parse.icon(icon$$1);
333
339
  }
package/index.js CHANGED
@@ -332,6 +332,12 @@
332
332
  }
333
333
 
334
334
  function normalizeIconArgs(icon) {
335
+ // this has everything that it needs to be rendered which means it was probably imported
336
+ // directly from an icon svg package
337
+ if (icon && (typeof icon === 'undefined' ? 'undefined' : _typeof(icon)) === 'object' && icon.prefix && icon.iconName && icon.icon) {
338
+ return icon;
339
+ }
340
+
335
341
  if (fontawesomeSvgCore.parse.icon) {
336
342
  return fontawesomeSvgCore.parse.icon(icon);
337
343
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fortawesome/vue-fontawesome",
3
3
  "description": "Official Vue component for Font Awesome 5",
4
- "version": "2.0.2",
4
+ "version": "2.0.3",
5
5
  "main": "index.js",
6
6
  "module": "index.es.js",
7
7
  "jsnext:main": "index.es.js",
@@ -4,6 +4,12 @@ import log from '../logger'
4
4
  import { objectWithKey, classList } from '../utils'
5
5
 
6
6
  function normalizeIconArgs (icon) {
7
+ // this has everything that it needs to be rendered which means it was probably imported
8
+ // directly from an icon svg package
9
+ if (icon && typeof icon === 'object' && icon.prefix && icon.iconName && icon.icon) {
10
+ return icon
11
+ }
12
+
7
13
  if (faParse.icon) {
8
14
  return faParse.icon(icon)
9
15
  }
@@ -30,10 +30,11 @@ export function mountFromProps (propsData = {}) {
30
30
  }
31
31
 
32
32
  export function coreHasFeature (feature) {
33
- if (feature === REFERENCE_ICON_BY_STYLE || feature === ICON_ALIASES) {
33
+ if (feature === REFERENCE_ICON_BY_STYLE || feature === ICON_ALIASES || feature === REFERENCE_ICON_USING_STRING) {
34
34
  return parse.icon
35
35
  }
36
36
  }
37
37
 
38
38
  export const REFERENCE_ICON_BY_STYLE = 0x00
39
- export const ICON_ALIASES = 0x01
39
+ export const ICON_ALIASES = 0x01
40
+ export const REFERENCE_ICON_USING_STRING = 0x02
@@ -1,15 +1,19 @@
1
1
  import Vue from 'vue/dist/vue'
2
2
  import FontAwesomeIcon from '../FontAwesomeIcon'
3
3
  import { library } from '@fortawesome/fontawesome-svg-core'
4
- import { faClose } from '@fortawesome/free-solid-svg-icons'
4
+ import { faClose, faUser } from '@fortawesome/free-solid-svg-icons'
5
5
  import { faCoffee, faCircle, faSpartan } from '../__fixtures__/icons'
6
- import { coreHasFeature, REFERENCE_ICON_BY_STYLE, ICON_ALIASES, compileAndMount, mountFromProps } from '../__fixtures__/helpers'
6
+ import { coreHasFeature, REFERENCE_ICON_USING_STRING, REFERENCE_ICON_BY_STYLE, ICON_ALIASES, compileAndMount, mountFromProps } from '../__fixtures__/helpers'
7
7
 
8
8
  beforeEach(() => {
9
9
  library.add(faCoffee, faCircle, faSpartan)
10
10
  Vue.component('font-awesome-icon', FontAwesomeIcon)
11
11
  })
12
12
 
13
+ afterEach(() => {
14
+ library.reset()
15
+ })
16
+
13
17
  test('using a FAT icon with array format', () => {
14
18
  const vm = mountFromProps({ icon: ['fat', 'spartan'] })
15
19
 
@@ -27,7 +31,7 @@ if(coreHasFeature(ICON_ALIASES)) {
27
31
  expect(vm.$el.classList.contains('fa-xmark')).toBeTruthy()
28
32
  })
29
33
 
30
- test('find a free-solid-svg-icon that is an alias ', () => {
34
+ test('find a free-solid-svg-icon that is an alias', () => {
31
35
  library.reset()
32
36
  library.add(faClose)
33
37
  const vm = mountFromProps({ icon: ['fas', 'close'] })
@@ -37,6 +41,22 @@ if(coreHasFeature(ICON_ALIASES)) {
37
41
  })
38
42
  }
39
43
 
44
+ if(coreHasFeature(REFERENCE_ICON_USING_STRING)) {
45
+ test('find an icon using string format', () => {
46
+ const vm = mountFromProps({ icon: 'fa-coffee' })
47
+
48
+ expect(vm.$el.tagName).toBe('svg')
49
+ expect(vm.$el.classList.contains('fa-coffee')).toBeTruthy()
50
+ })
51
+
52
+ test('find an icon using string format with style', () => {
53
+ const vm = mountFromProps({ icon: 'fa-solid fa-coffee' })
54
+
55
+ expect(vm.$el.tagName).toBe('svg')
56
+ expect(vm.$el.classList.contains('fa-coffee')).toBeTruthy()
57
+ })
58
+ }
59
+
40
60
  if (coreHasFeature(REFERENCE_ICON_BY_STYLE)) {
41
61
  test('find a THIN icon with array format', () => {
42
62
  const vm = mountFromProps({ icon: ['thin', 'spartan'] })
@@ -67,6 +87,12 @@ test('using string format', () => {
67
87
  expect(vm.$el.classList.contains('fa-coffee')).toBeTruthy()
68
88
  })
69
89
 
90
+ test.only('using imported object from svg icons package', () => {
91
+ const vm = mountFromProps({ icon: faUser })
92
+
93
+ expect(vm.$el.tagName).toBe('svg')
94
+ })
95
+
70
96
  test('missing icon', () => {
71
97
  const vm = mountFromProps({ icon: ['fas', 'noicon'] })
72
98