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

component update clears innerHTML? #19

Closed
fritx opened this issue Jan 5, 2016 · 10 comments
Closed

component update clears innerHTML? #19

fritx opened this issue Jan 5, 2016 · 10 comments

Comments

@fritx
Copy link

fritx commented Jan 5, 2016

<Editor ref="edit" id="editor" className="edit"
              style={{
                fontFamily: fields.fontFamily.value,
                fontSize: fields.fontSize.value,
                fontWeight: fields.fontBold.value ? 'bold' : 'normal',
                color: fields.fontColor.value,
              }}
              onKeyDown={(e)=>this.onKeyDown(e)}
              onInput={(e)=>this.onInput(e)}
              dangerouslySetInnerHTML={{__html: currConver.editor}} />

It seems the innerHTML clears when one of the css style updates.
When I switch back to react, it works.
Is it a bug of react-lite?

@Lucifier129
Copy link
Owner

I wonder the type of currConver.editor, it's string or not?

since:

let oldHtml = oldValue && oldValue.__html
let html = value && value.__html
if (!isStr(html)) {
  elem.innerHTML = ''
} else if (html !== oldHtml) {
  elem.innerHTML = html
}

@Lucifier129
Copy link
Owner

if currConver.editor is equal to undefined, innerHTML will also be clears.

Had better got a demo for debugging:)

@fritx
Copy link
Author

fritx commented Jan 5, 2016

Yes, you're right. It is undefined 😢
But this is different with React. Is it better to make them consistent? ;)

@Lucifier129
Copy link
Owner

@fritx That's ok, I will check the behavior about inneHTML in this case with react, and make them consistent.

@fritx
Copy link
Author

fritx commented Jan 6, 2016

Thanks! At this time, I prefer consistancy. Thank you!
But maybe in the future, react-lite's simplicity and lightweight wins!

@Lucifier129
Copy link
Owner

I think the version v0.0.13 of react-lite made consistancy with below change:

let oldHtml = oldValue && oldValue.__html
let html = value && value.__html
if (html != null && html !== oldHtml) {
  elem.innerHTML = html
}

It won't be patched if html is equal to null or undefined such like regular react does.

try the lastest version to confirm this problem was resolved:)

BTW, I think regular react will provide lightweight version in the feature, or something like rollup \ tree shaking, make react-lite not necessary

haha ~ just wait and see what will happen.

@fritx
Copy link
Author

fritx commented Jan 7, 2016

@Lucifier129 haha~ ok, wait a sec

@fritx
Copy link
Author

fritx commented Jan 7, 2016

Ok alright!

  • It won't be patched if html is equal to null or undefined
  • It will be patched if html is equal to empty string

@Lucifier129
Copy link
Owner

That's good:)

@dhenson02
Copy link

issue should be closed 👍

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

3 participants