Giter Club home page Giter Club logo

Comments (4)

ChristianKienle avatar ChristianKienle commented on August 28, 2024

@droshev I think that this is already possible. Vue automatically renders attributes (that are not registered as a prop) unless this is specifically turned off. This means that an application developer can to something like this:

<FdIdentifier title="Foo Bar" />

This will render the standard identifier and on hover a tooltip saying Foo Bar will be displayed (standard behaviour).

This also works when using (Fd)Identifier internally. However, Typescript will complain when compiling this:

<Identifier title='Foo Bar' />

Typescript rightfully complains. However you can still execute the resulting Vue app and everything will also work (despite the error message).

This is the case because Typescript only recognizes declared component props (by using the typical Props-interface) and well know attributes (declared in ./vue-tsx.ts). I have only added a handful of well known attributes to our configurution:

// KnownAttrs inspired by wonderful-panda
// MIT License
// Copyright (c) 2017 wonderful-panda
// Full License: https://github.com/wonderful-panda/vue-tsx-support/blob/master/LICENSE
// GitHub Project: https://github.com/wonderful-panda/vue-tsx-support
// Thanks!
type KnownAttributeName = 'class' | 'staticClass' | 'key' | 'ref' | 'slot' | 'scopedSlots';
type KnownAttrs = Pick<VNodeData, KnownAttributeName> & {
  style?: VNodeData['style'] | string;
  id?: string;
  refInFor?: boolean;
  domPropsInnerHTML?: string;
};

We now have several options:

  1. We can simply add title to the KnownAttrs-type. (-1 from me)
  2. If you want to set the title you could to it like this:
<Identifier domPropsTitle='Foo Bar' />

This works today. Without changing anything.
What do you think?

from fundamental-vue.

LinusBorg avatar LinusBorg commented on August 28, 2024

<Identifier domPropsTitle='Foo Bar' />

While that "works", I think it does something fundamentally different: it doesn't set the title attribute, instead it sets the correcsponding element property through javascript (pseudocode):

el.title = vnode.domProps.title

Have you considered just extending the KnownAttributes with a complete list, like vue-tsx-support does?

from fundamental-vue.

ChristianKienle avatar ChristianKienle commented on August 28, 2024

Have you considered just extending the KnownAttributes with a complete list, like vue-tsx-support does?

Thanks for the clarification. This is certainly something completely different. It seems that I didn't think about it hard enough.

Maybe we should simply do what the rest of the tsx-consuming world is doing. :D

from fundamental-vue.

ChristianKienle avatar ChristianKienle commented on August 28, 2024

Fixed.

from fundamental-vue.

Related Issues (20)

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.