Hyperhtml: Uncaught TypeError: Cannot use 'in' operator to search for 'ELEMENT_NODE' in null

Created on 16 Jun 2018  路  5Comments  路  Source: WebReflection/hyperHTML

I get the Following error when reordering an array used to render items:
Uncaught TypeError: Cannot use 'in' operator to search for 'ELEMENT_NODE' in null

The weird thing is that it only happens with one set of data but not the other one.

Here is one codepen where it is working: https://codepen.io/jaschaio/pen/gKxeVx

Here is another one where it throws the error: https://codepen.io/jaschaio/pen/MXJzQw

Just try changing the Order by: select field.

The only difference is between the two is the array that is used to render the items. The array structure is exactly the same, but one throws said error and I just can't understand where its coming from.

It somehow seems to be caused by using hyperHTML.wire( this, ':post-' + item.id ) in line 15. If I change it to hyperHTML.wire( this, ':post-' + index ) no error is thrown. But the index changes depending on how I order the items, so the most performant option should be using item.id for the unique ID instead of index.

Most helpful comment

It looks like you've accidentally discovered a very nasty bug hidden in the domdiff algorithm.

Everything has been fixed now, and tests were added too.

The minimal way to reproduce the issue is through this bug:
https://github.com/WebReflection/domdiff/issues/6#issue-333192475

I'm so happy I've spotted this issue so thank you very much for filing this ticket.

All 5 comments

if those items are not exposed, you can use the index without any issue, the result is that more items might get those parts updated, but updates are super cheap and fast in hyperHTML.

However, I don't fully understand what's the different between these two demoes, but something tells me you have duplicated IDs in your JSON data so stuff doesn't work as expected.

It looks like you've accidentally discovered a very nasty bug hidden in the domdiff algorithm.

Everything has been fixed now, and tests were added too.

The minimal way to reproduce the issue is through this bug:
https://github.com/WebReflection/domdiff/issues/6#issue-333192475

I'm so happy I've spotted this issue so thank you very much for filing this ticket.

yup, fixed in 2.10.11, sorry for that.

@WebReflection Great to hear that! I was initally refraining from filling this ticket for two days as I thought that it was probably my mistake. Thanks so much for taking another look. Not being able to grasp why it wasn't working was driving me crazy 馃槀

@jaschaio apologies I didn't have a deeper look initially, so I thought it must've been same ID appended twice, hence some glitch, it turned out to be a very disaster-prone issue with the domdiff algo , happy I've spotted that.

If you write code that makes sense and it doesn't work, please don't hesitate to open bugs.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janrembold picture janrembold  路  8Comments

BentleyDavis picture BentleyDavis  路  8Comments

liming picture liming  路  7Comments

shanghaikid picture shanghaikid  路  8Comments

pmowrer picture pmowrer  路  5Comments