Git Product home page Git Product logo

svelte-inline-svg's People

Contributors

captinkraken avatar dependabot[bot] avatar eriandev avatar james-camilleri avatar robinscholz avatar xeho91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

svelte-inline-svg's Issues

Add basic TS typings

This package throws up errors when using Svelte with TypeScript, I was wondering if it would be possible to include basic typings for the component. I've prepared a very simple set, it shouldn't be too much hassle to add.

import { SvelteComponentTyped } from 'svelte'

export declare class InlineSvgProps {
    src: string
    transformSrc: (src: SVGElement) => SVGElement
    [attribute: string]: any
}

export default class InlineSvg extends SvelteComponentTyped<InlineSvgProps> {
}

The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.

Hi, and thanks for a very helpful package.

Recently I've noticed that it returns the following Warning:

[vite-plugin-svelte] WARNING: The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.

[email protected]

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#conflicts-in-svelte-resolve for details.

The details mentioned above is in package.json to move "svelte": "src/index.js", into exports:

"exports": {
    ".": {
      "require": "./dist/index.js",
      "import": "./dist/index.mjs",
      "svelte": "./src/index.js"     // <- new 
    },
    "./package.json": "./package.json"
  },

Note the initial ./.

Can't compile because "src" is excluded

In package.json the svelte field refers to src/index.js but it is not included in the files field so the component can't be compiled in a rollup-plugin-svelte (or svelte-loader) project.

Does not inline anything in Sveltekit

Lib does not work in Sveltekit. It renders only empty svg:

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240" fill="red">
<!-- HTML_TAG_START -->
undefined
<!-- HTML_TAG_END -->
</svg>

But, if i copy it in project and use it from there, it somehow works

svelte-inline-svg: 1.2.0
Node: 16.15.1
Sveltekit: 1.27.4
Svelte: 4.2.7

同学,您这个项目引入了413个开源组件,存在1个漏洞,辛苦升级一下

检测到 robinscholz/svelte-inline-svg 一共引入了413个开源组件,存在1个漏洞

漏洞标题:Mikaelbr Node-notifier 操作系统命令注入漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2020-7789
漏洞描述:Mikaelbr Node-notifier是Mikaelbr个人开发者的一个基于Javascript的用于为Mac、Windows、Linux发送**的代码库。
node-notifier 9.0.0之前版本存在安全漏洞,该漏洞允许攻击者可利用该漏洞在Linux机器上运行任意命令,因为在传递数组时,选项参数没有被清除。
影响范围:[8.0.0, 8.0.2)
最小修复版本:8.0.2
缺陷组件引入路径:[email protected]>[email protected]>[email protected]>@jest/[email protected]>@jest/[email protected]>[email protected]
[email protected]>[email protected]>@jest/[email protected]>@jest/[email protected]>[email protected]

另外还有几个漏洞,详细报告:https://mofeisec.com/jr?p=i3c713

Local File Paths for src not working

According to the README.md, this is a valid src: const src = '/path/to/file.svg'

This won't work for me, so I read through the source and looks like the library supports a url since a fetch request is made, not local file paths as per above.

Please clarify the docs as to intended usage or add support for local file paths.

SVG not embedded with SSR

Hi,

I've added the svg and all looks good, but the SVG is not actually included in the HTML. All I get is this:

<svg xmlns="http://www.w3.org/2000/svg" contenteditable="true"></svg>

There is no error either.

I noticed this because I turned off JS to see what the site looks like before it's hydrated.

Missing file in dist

Looks like mjs file is missing in the dist that published on NPM. It's pointed out in package.json, but is actually not present. This breaks Snowpack for example. Should be an easy fix.

SSR Support

When using svelte-inline-svg I get the error:

Error: <InlineSVG> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
    at validate_component (/home/ixxie/repos/coflow/node_modules/svelte/internal/index.mjs:1343:18)
    at /home/ixxie/repos/coflow/__sapper__/dev/server/server.js:343:50
    at Object.$$render (/home/ixxie/repos/coflow/node_modules/svelte/internal/index.mjs:1366:23)
    at /home/ixxie/repos/coflow/__sapper__/dev/server/server.js:362:157
    at Object.$$render (/home/ixxie/repos/coflow/node_modules/svelte/internal/index.mjs:1366:23)
    at Object.default (/home/ixxie/repos/coflow/__sapper__/dev/server/server.js:373:64)
    at /home/ixxie/repos/coflow/__sapper__/dev/server/server.js:312:83
    at Object.$$render (/home/ixxie/repos/coflow/node_modules/svelte/internal/index.mjs:1366:23)
    at /home/ixxie/repos/coflow/__sapper__/dev/server/server.js:372:36
    at Object.$$render (/home/ixxie/repos/coflow/node_modules/svelte/internal/index.mjs:1366:23)

In my log I also get informed:

[rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.

- svelte-inline-svg

Am I doing something wrong or is this indeed as the error says, an issue with exports in this package?

event warning in dev console: [Violation] Added non-passive event listener to a scroll-blocking ...

Using this component throws warning in chrome console:

index.mjs:413 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
index.mjs:413 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
index.mjs:413 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

contenteditable="true"?

I know it's a small thing, but I want to know why rendered SVGs are added contenteditable="true"?
All SVG properties should be chosen by the user and not have things that are not necessary by themselves.

While running jest InlineSVG is having an error of 'Not a constructor' in svelte.

Hey, this package works great except for svelte-jester testing. Not sure if I should be putting this issue there or here.

jest: 27.5.0
svelte-jester: 2.3.1
svelte: 3.44.2
svelte-inline-svg: ^1.1.1
typescript: 4.5.5

I'm not entirely sure what information you need to re-create the issue.

TypeError: InlineSVG is not a constructor

      at Array.create_if_block (src/Components/PaymentIcon/PaymentIcon.svelte:237:14)
      at create_fragment (src/Components/PaymentIcon/PaymentIcon.svelte:305:94)
      at init (node_modules/svelte/internal/index.js:1809:37)
      at new PaymentIcon (src/Components/PaymentIcon/PaymentIcon.svelte:411:3)
      at create_fragment (src/Components/PaymentType/PaymentType.svelte:38:16)
      at init (node_modules/svelte/internal/index.js:1809:37)
      at new PaymentType (src/Components/PaymentType/PaymentType.svelte:193:3)
      at render (node_modules/@testing-library/svelte/dist/pure.js:81:21)
      at Object.<anonymous> (src/Components/PaymentType/PaymentType.spec.ts:19:33)
  -- PaymentIcon.svelte --
<script lang="ts">

  import "../../SharedStyles/paymentIcon.scss";

  import Amex from "../../Icons/Amex.svg";
  import Discover from "../../Icons/Discover.svg";
  import Mastercard from "../../Icons/Mastercard.svg";
  import PayPal from "../../Icons/PayPal.svg";
  import Visa from "../../Icons/Visa.svg";
  import InlineSVG from "svelte-inline-svg";

  export let iconName: string;
</script>

{#if iconName === "visa"}
  <div class="payment-icon">
    <InlineSVG src={Visa} />
  </div>
{:else if iconName === "mastercard"}
  <div class="payment-icon">
    <InlineSVG src={Mastercard} />
  </div>
{:else if iconName === "discover"}
  <div class="payment-icon">
    <InlineSVG src={Discover} />
  </div>
{:else if iconName === "amex"}
  <div class="payment-icon">
    <InlineSVG src={Amex} />
  </div>
{:else if iconName === "paypal"}
    <InlineSVG id="paypalIcon" src={PayPal} />
{:else}
  {iconName}
{/if}

-- PaymentIcon.spec.ts --

import { render } from "@testing-library/svelte";
import PaymentIcon from "./PaymentIcon.svelte";

describe("tests payment icon snapshots", () => {
  test("should match visa snapshot", () => {
    const props = { iconName: "visa" };
    const { container } = render(PaymentIcon, { ...props });
    expect(container).toMatchSnapshot();
  });
  test("should match mastercard snapshot", () => {
    const props = { iconName: "mastercard" };
    const { container } = render(PaymentIcon, { ...props });
    expect(container).toMatchSnapshot();
  });
  test("should match discover snapshot", () => {
    const props = { iconName: "discover" };
    const { container } = render(PaymentIcon, { ...props });
    expect(container).toMatchSnapshot();
  });
  test("should match amex snapshot", () => {
    const props = { iconName: "amex" };
    const { container } = render(PaymentIcon, { ...props });
    expect(container).toMatchSnapshot();
  });
  test("should match paypal snapshot", () => {
    const props = { iconName: "paypal" };
    const { container } = render(PaymentIcon, { ...props });
    expect(container).toMatchSnapshot();
  });
  test("should match error snapshot", () => {
    const { container } = render(PaymentIcon, { iconName: "" });
    expect(container).toMatchSnapshot();
  });
});
      

Trouble rendering SVGs from node modules

After you resolved the previous issue I had with SSR, I now tried to apply svelte-inline-svg to my project. I am trying to render SVGs from the openmoji library.

The library returns the absolute path of the SVG files (stored in the /node_modules/ folder), and I double checked this is indeed correct; but somehow, I am not managing to render this SVG file. I get no error, but the SVG doesn't render. I'm probably just doing something wrong, and I apologize if I am abusing the issue feature for support, since I am not sure how else to proceed!

I updated the minimal example repository I used for the previous issue to demonstrate this issue with a minimal example.

Could not resolve './utils/forwardEvents'

Hi there

There seems to be something off in the newest release on npm... ForwardEventsBuilder is imported, but the utils folder does not exist (in the npm-package at least. I see that it does in the main branch).

I'm getting the following node error:

Could not resolve './utils/forwardEvents' from node_modules\svelte-inline-svg\src\inline-svg.svelte
node:internal/modules/cjs/loader:944
  throw err;
  ^

Thanks a lot for fixing this!

Clicking on svg shows border

I am trying to use svelte-inline-svg on my Sveltekit project. It embeds just fine and shows up on my webpage

However, when I click on the SVG, it shows an ugly black border around the SVG.

How can I get rid of this behavior and not have a border show up on clicking on the SVG ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.