Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what about enumeratedAttr?currently as a base attribute is feasible? #8689

Closed
MurakamiKennzo opened this issue Aug 22, 2018 · 5 comments
Closed

Comments

@MurakamiKennzo
Copy link

What problem does this feature solve?

hi, I'm very happy to use vue to build my app. and now I will start to read some source code, and I find in html attributes, there is isEnumeratedAttr exist, and I think treat it as a base attribute is feasible, although some unreasonable maybe? can anyone help me?

export const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck')

here is what the function use:

function setAttr (el: Element, key: string, value: any) {
  if (el.tagName.indexOf('-') > -1) {
    baseSetAttr(el, key, value)
  } else if (isBooleanAttr(key)) {
    // set attribute for blank value
    // e.g. <option disabled>Select one</option>
    if (isFalsyAttrValue(value)) {
      el.removeAttribute(key)
    } else {
      // technically allowfullscreen is a boolean attribute for <iframe>,
      // but Flash expects a value of "true" when used on <embed> tag
      value = key === 'allowfullscreen' && el.tagName === 'EMBED'
        ? 'true'
        : key
      el.setAttribute(key, value)
    }
  } else if (isEnumeratedAttr(key)) {
    el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true')
  } else if (isXlink(key)) {
    if (isFalsyAttrValue(value)) {
      el.removeAttributeNS(xlinkNS, getXlinkProp(key))
    } else {
      el.setAttributeNS(xlinkNS, key, value)
    }
  } else {
    baseSetAttr(el, key, value)
  }
}

What does the proposed API look like?

delete isEnumeratedAttr, treat it as base attribute maybe.

@posva
Copy link
Member

posva commented Aug 23, 2018

I honestly don't understand what you wrote or if there is anything actionable here

Maybe you could use the forum or the Discord server the discuss about this and come back with a different formulation 🙂

@posva posva closed this as completed Aug 23, 2018
@jacekkarczmarczyk
Copy link

I guess it's about vuejs/core#1350 (comment)

@posva
Copy link
Member

posva commented Jun 12, 2020

spellcheck seems to properly work on Vue 2 though: it results in spellcheck="false" or spellcheck="true"

@serdaronedio
Copy link

serdaronedio commented Sep 29, 2021

Hi @MurakamiKennzo ;

I know this is old issues but we met some errors like this. Error is:

TypeError · Cannot read properties of undefined (reading 'indexOf')

And the code is:

function setAttr (hand, key, value, isInPre) {
if (isInPre || el.tagName.indexOf('-') > -1) { // tips: highlight this line by error report
baseSetAttr(hand, key, value);
} else if (isBooleanAttr(key)) {
// any code ...
// any code ...
}

And, we hadn't found any result about this error. We use nuxt.js v2.15.7 and vue-lazy-hydration v2.0.0-beta.4 (latest version). We get this error on almost all pages. Did you able to be figured this error out before?

@MurakamiKennzo
Copy link
Author

MurakamiKennzo commented Sep 29, 2021

Hi @MurakamiKennzo ;

I know this is old issues but we met some errors like this. Error is:

TypeError · Cannot read properties of undefined (reading 'indexOf')

And the code is:

function setAttr (hand, key, value, isInPre) { if (isInPre || el.tagName.indexOf('-') > -1) { // tips: highlight this line by error report baseSetAttr(hand, key, value); } else if (isBooleanAttr(key)) { // any code ... // any code ... }

And, we hadn't found any result about this error. We use nuxt.js v2.15.7 and vue-lazy-hydration v2.0.0-beta.4 (latest version). We get this error on almost all pages. Did you able to be figured this error out before?

maybe you need replace el to hand?

if not, where's your el coming from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants