Giter VIP home page Giter VIP logo

Comments (16)

hunter2009 avatar hunter2009 commented on July 17, 2024

这个有点奇怪,xhml元素必须被关闭,当允许自闭合的话总感觉有好多坑,对于结构化的阅读也不是很好...

from san.

otakustay avatar otakustay commented on July 17, 2024

我并没有不关闭啊,<ui-calendar />不就是关闭的么……

from san.

Justineo avatar Justineo commented on July 17, 2024

所有标签都自闭合?感觉还是让组件自己声明是不是 void 比较好?

from san.

otakustay avatar otakustay commented on July 17, 2024

我是指允许自闭合,并不是强制……即在模板解析时看到/>就当做></xxx>就行了……

from san.

Justineo avatar Justineo commented on July 17, 2024

解析到 > 如果根据 tagName 发现是 void 组件就当做完结了不好吗?

from san.

otakustay avatar otakustay commented on July 17, 2024

那么会出现2个问题:

  1. 对于自定义组件,就必须由组件提供是否void信息
  2. 对于非void但就想闭合的(比如有个slot但默认的内容能满足所以不自定义),无法自闭合

from san.

Justineo avatar Justineo commented on July 17, 2024

哦,你主要是想支持「可以自闭合也可以不自闭合」的情况,这个好像就没法和 HTML 保持一致了。

from san.

otakustay avatar otakustay commented on July 17, 2024

从模板这个层面上,我觉得就没打算和HTML一致,让人用最舒服的方法写出可以解析为aNode的东西更重要一些……

from san.

erik168 avatar erik168 commented on July 17, 2024

我觉得还是要符合HTML,省的有教育成本,也省得使用者觉得卧槽什么鬼。所以我还是不赞成

的。input本来就是自动闭合的,不用写 />。比起“思考这里到底能不能直接闭合”,我闭合标签已经写完了。

HTML有个sb地方是script必须</script>,大家写了这么多年也没见几个人吐槽。所以�我觉得这不是啥问题。

@Justineo custom elements是不是默认允许直接在自身闭合的?如果是的话,我觉得custom element可以支持这个feature

from san.

otakustay avatar otakustay commented on July 17, 2024

HTML里没有自闭合这个概念,只有void element,所以如果你要符合HTML,就根本不存在/>这个东西(/>会被认为是>,纯语法上),HTML就是规定了一些元素不能有end tag而已

对于custom element,从规范上来说,不行,所以你要真认为自己的模板是HTML,你就要处理<input>等的无闭合标签问题,且所有自定义组件必须写闭合标签

我觉得这样太麻烦了……

from san.

erik168 avatar erik168 commented on July 17, 2024

我们还是很**的,回头投个票吧 @otakustay

from san.

erik168 avatar erik168 commented on July 17, 2024

@Justineo 主席发起在tc级别

from san.

musicode avatar musicode commented on July 17, 2024

我的想法是,对于常用的几个标签,br、img、input 可以不加 />

好像我也没怎么用过其他自闭合标签....

对于组件来说,如果组件有识别方式,如包含大写字母或连字符,也支持不写 />

对于其他无法判断是否自闭合的元素,必须加 />,比如 SVG 里的 path,即可以是 <path /> 也可以是 <path></path>,但不能是 <path>

from san.

otakustay avatar otakustay commented on July 17, 2024

我的理解基本和楼上一致:

  1. 无论什么标签,都能写/>
  2. 对于几个HTML规定的void element,特殊处理无/>的场景
  3. 基于上面2条,总之生成的aNode里就是一个元素,无关是自定义的还是原生的
  4. 再把这个元素变成HTML就行

from san.

musicode avatar musicode commented on July 17, 2024

无耻地做一波广告 yoxjs

from san.

errorrik avatar errorrik commented on July 17, 2024

@musicode 你在这广告有毛用。。。

看了下现在的实现,是支持的。所以我关了

from san.

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.