Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

virtualize ignores readonly attribute #31

Open
Kinrany opened this issue Jun 10, 2018 · 1 comment
Open

virtualize ignores readonly attribute #31

Kinrany opened this issue Jun 10, 2018 · 1 comment

Comments

@Kinrany
Copy link

Kinrany commented Jun 10, 2018

Calling virtualize on a string that has a readonly attribute with no value results in a non-read-only virtual node.

Works as expected with empty value:

virtualize('<input readonly="" />')

Output:

{ 
  sel: 'input',
  data: { attrs: { readonly: '' } },
  children: undefined,
  text: undefined,
  elm: undefined,
  key: undefined 
}

Doesn't work with no value:

virtualize('<input readonly />')

Expected output, same as h('input', { attrs: { readonly: undefined } }):

{ 
  sel: 'input',
- data: { attrs: { readonly: '' } },
+ data: { attrs: { readonly: undefined } },
  children: undefined,
  text: undefined,
  elm: undefined,
  key: undefined 
}

Output:

{ 
  sel: 'input',
- data: { attrs: { readonly: '' } },
+ data: {},
  children: undefined,
  text: undefined,
  elm: undefined,
  key: undefined 
}

Interactive example: https://repl.it/@Kinrany/snabbdom-virtualize-bug

@Kinrany
Copy link
Author

Kinrany commented Jun 11, 2018

Most likely caused by unescapeEntities(text, context) from utils.js.

It expects text to be a string and uses String.prototype.replace.

I guess a simple empty string default parameter would let it handle undefined properly. Not sure if there are other cases, like null.

Kinrany added a commit to Kinrany/snabbdom-virtualize that referenced this issue Jun 11, 2018
Kinrany added a commit to Kinrany/snabbdom-virtualize that referenced this issue Jun 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant