wooorm / property-information

Info on the properties and attributes of the web platform
MIT License
38 stars 11 forks source link

Provide flag to mark unknown attribute #9

Closed StarpTech closed 6 years ago

StarpTech commented 6 years ago

Hi, I need to check if an attribute is a known HTML attribute or not. I do it in this way:

info.property === info.attribute // unknown

I think it would be good to provide a flag like unknown: true

wooorm commented 6 years ago

I think that wouldn’t work for things like id, where the prop is equal to the attribute.

What would work is info.space === undefined && info.property === info.attribute && info.property !== 'role', because everything except for ARIA has a namespace attached, and ARIA always has different casing, except for role.

I’m OK with something like unknown, but don’t like that word. data properties are all “unknown”, but they are still handled properly!

StarpTech commented 6 years ago

I think you mean

!info.space && info.property === info.attribute && info.property !== 'role'

space is just not set in that case.

What's your suggestion for the name?

wooorm commented 6 years ago

space is just not set in that case.

not defined and explicitly set to undefined both evaluate to undefined!

What's your suggestion for the name?

not sure 🤔 do you have suggestions?

StarpTech commented 6 years ago

not defined and explicitly set to undefined both evaluate to undefined!

That's true but not in this case. The property is on the prototype and does exist.

'space' in info // true

Correct would be

    info.space === null &&
    info.property === info.attribute &&
    info.property !== 'role'
wooorm commented 6 years ago

Ah, I totes forgot about the prototype. Good catch!

What still remains is how to call the prop! 🤷‍♂️

StarpTech commented 6 years ago

not sure 🤔 do you have suggestions?

e.g

StarpTech commented 6 years ago

userDefined: true

wooorm commented 6 years ago

How about specified, as in, it’s specified by a spec (or not)?

Others:

(I think I’d rather not have double negatives, I prefer defined: true instead of undefined: false)

StarpTech commented 6 years ago

I think 🤔 specified is great :+1:

wooorm commented 6 years ago

Alternatively still defined, as it’s shorter and people type it a lot (because of undefined). Or even found, as the primary way to get these Info object is through .find().

Anyway, feel free to pick one and create a PR. We can easily replace a word with something else when we have some actual code!

StarpTech commented 6 years ago

Allright, I will create a PR soon.

StarpTech commented 6 years ago

I think it's better to opt-out this property because it only affects custom properties. Do you have a better name for this? specified or defined would affect all known attributes.

WDYT about custom (like custom element/attribute) or just new ?

wooorm commented 6 years ago

We could add it to the prototype, and potentially also create an UnspecifiedProperty with specified: false or so?

wooorm commented 6 years ago

or DefinedProperty / UndefinedProperty, etc etc