Git Product home page Git Product logo

Comments (23)

WebReflection avatar WebReflection commented on May 27, 2024 2

So ... 2.18 coincidentally comes from 2018 cf6bbed ... but we are in 2021 ... although the change that bugs you is from 10th of May 2019 6262e1d

that changes in particular deals with legacy, and it feels like you're either not interested in it, or you're late to the update hyperHTML party.

Now ... as previously mentioned, hyperHTML had an ambiguity there, and to opt out from such ambiguity, you have now either ?attr or .attr ... the latter is for accessors.

The .disabled=${...} is exactly what you are looking for, and since this library won't break backward compatibility from 2019 today, or ever, I strongly suggest you switch to that syntax, when you mean to access the element.attribute instead, so that nothing will ever be a surprise.

I guess updating has these costs, but at least here it's clear what you should update.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024 1

You don’t reach that code and yes, double (( )) means intentional

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024 1

I'll try to reproduce it.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024 1

absolutely, as once again, you never touch new code if you haven't changed templates ... but without anything to reproduce, not even via the latest, only you can find out where it broke, why, or how ...

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

wait ... the breaking change wasn't meant, and ?disabled=${value} is opt-in, not mandatory ... are you using ?disabled or just disabled?

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

to clarify, nothing touches the previous behavior here and that's what went out

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

We used it without the ?. Several of our integration tests broke because of the upgrade.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

From which version?

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

Just a quick check on the code:
Line 1501 in index.js has a single = in the if condition. Was this intentional?

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

ac14025#diff-a1e35bf752b708a7f4ff7570d938ff532b7c714aa45ca92dd6f9b5dae70a677aR56

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

Don’t look at anything that is not under esm folder, just to clarify

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

Just trying to make sense of the code, maybe I'm completely off track:

hyperHTML/index.js

Lines 1622 to 1628 in 7a89190

if (newValue == null) {
if (owner) {
owner = false;
node.removeAttributeNode(attribute);
}
attribute.value = newValue;

If I'm correct this is the snippet that runs for using disabled=${null}. In this case shouldn't the function return after removing the attribute on line 1625? It seems to be contradictory to remove an attribute then assigning a new value to it on line 1628.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

I've tested the code (as there are a lot of tests, we use this in production) and I cannot reproduce the issue ... can you reproduce the issue? Again, nothing changed in here in 2.34, you never reach changed code if there's no ?disabled=${...}

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

also, like I've said, I won't comment on anything that is not under the esm/ folder, as nothing else matters.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

last, but not least, the attribute value is syncd'

if (attribute.value !== newValue) {

can you help me reproducing this issue? I think you have something else going on there ... I can't reproduce this issue.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

anyway, this is the only change and nothing else changed ... so I am pretty confident you have some other issue, or somebody started passing along different values (not null) somewhere else.

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

We were upgrading from version "2.18.0". Could the issue lie somewhere else? 🤔

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

I managed to reproduce the issue. The problem lies with custom elements, their property setters specifically.

https://jsfiddle.net/4cv5eahg/

With version 2.18.0 the value null is received by the setter, in version 2.32.0 an empty string is passed.
Adding the ? to the render in line 38 prevents the setter to be called altogether.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

I read null ... which is expected, it passes whatever value to the setter, and this is not going to change ... have you perhaps changed polyfill for custom elements?

the current behavior in your test is expected from Custom Elements, it looks like it was broken before.

from hyperhtml.

vimtaai avatar vimtaai commented on May 27, 2024

If you change the hyperHTML version in the HTML file (I put both versions there, just change the comment) to 2.32.0 then on the console it shows an empty string being recieved by the setter.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

Just FYI, if you want to trigger the accessor, you can use the never ambiguous .disabled=${value} syntax, and the accessor will receive any value, not just strings.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

Everything else is explained in the latest update: hyperHTML is ambiguous when no specialized syntax is used in the template, and it works unpredictably if the component is defined before or after the element gets created.

this is a known gotcha of custom elements in general, and cannot be fixed in here.

As 2.34 has nothing to do with this, I’ll close this issue as it looks to me everything works as expected, but you were relying on a previous bug.

from hyperhtml.

WebReflection avatar WebReflection commented on May 27, 2024

If you change the hyperHTML version in the HTML file (I put both versions there, just change the comment) to 2.32.0 then on the console it shows an empty string being recieved by the setter.

I've missed this, apologies ... checking out

from hyperhtml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.