framework icon indicating copy to clipboard operation
framework copied to clipboard

We have no vanilla JSArtifacts

Open Shadowfiend opened this issue 8 years ago • 13 comments

Currently we only have JSArtifacts subclasses for JQuery, YUI, and ExtCore. While we've been toiling away to provide the core of our JS functionality in a library-agnostic “vanilla” setup, there's currently no JSArtifacts implementation that can be used with that.

We'll want to tread somewhat carefully here, but this implementation can simply be modern-browser-only, which should make it fairly straightforward to implement.

For now, let's aim for the 3.1 cycle for this guy… We were hoping to have liftVanilla in a usable state by then in earlier discussions.

Shadowfiend avatar Apr 22 '17 13:04 Shadowfiend

I'm working on some other issues here right now, but can I call dibs on this one please?

Bhashit avatar Jun 18 '17 07:06 Bhashit

@Bhashit I have no issue with that, and I doubt Antonio will, but just check again whenever you're ready to actually start work. =)

farmdawgnation avatar Jun 18 '17 13:06 farmdawgnation

Yeah gimme a heads up and I'll do the same if I start on it.

Shadowfiend avatar Jun 24 '17 20:06 Shadowfiend

@Shadowfiend I'm ready to start work on this, unless someone's already doing it.

Bhashit avatar Jul 10 '17 03:07 Bhashit

Whoops, didn't reply here… I've got my hands full elsewhere, so go for it!

Shadowfiend avatar Jul 22 '17 20:07 Shadowfiend

A bit too late than I would have liked, but I have just started work on this.

Bhashit avatar Nov 01 '17 15:11 Bhashit

Awesome!

Shadowfiend avatar Nov 01 '17 15:11 Shadowfiend

Had a few questions/observations about how we want to proceed with certain things.

Some of the functions that we need to implement are toggle, hide and show. When we hide an element and show it back, we'll need to keep track of its previous value of the style.display attribute. I mean, it's possible that the display style attrib was set to some non-default value. I'm thinking of keeping track of using an object hidden in a closure.

One more important thing I wanted to ask was: how complicated do we want to make this? I think this was more targeted at modern browsers, and getComputedStyle is pretty well supported. So, I was thinking of going with that.

What jQuery does additionally is to try and find the default value for display attrib by adding a temp element when it can't find a value normally. Do we want to add that?

One additional question: if we add a bunch of JS code, should it still be included the scala code?

Bhashit avatar Nov 05 '17 04:11 Bhashit

Some of the functions that we need to implement are toggle, hide and show. When we hide an element and show it back, we'll need to keep track of its previous value of the style.display attribute. I mean, it's possible that the display style attrib was set to some non-default value. I'm thinking of keeping track of using an object hidden in a closure.

I would actually prefer we use the display attribute that comes with the DOM instead of rolling our own object that we close over and track. We may not be the only JavaScript on the page that's tinkering with how things display, and reading the DOM is the best way to make sure we're not stepping on the feet of other libraries.

One more important thing I wanted to ask was: how complicated do we want to make this? I think this was more targeted at modern browsers, and getComputedStyle is pretty well supported. So, I was thinking of going with that.

Glancing at the supported chart for getComputedStyle seems fine to me. Anyone who really needs to worry about browser capability can always flip on the jQuery module and pull in jQuery 1.x that still has support back to IE6.

What jQuery does additionally is to try and find the default value for display attrib by adding a temp element when it can't find a value normally. Do we want to add that?

Using getComputedStyle may mean we don't need to do this, unless I'm mistaken.

One additional question: if we add a bunch of JS code, should it still be included the scala code?

I don't understand this question so I don't know how to answer it. :)

farmdawgnation avatar Nov 05 '17 20:11 farmdawgnation

The goal of liftVanilla was definitely to lean on modern browser implementations as much as possible.

Shadowfiend avatar Nov 05 '17 23:11 Shadowfiend

Thanks @farmdawgnation @Shadowfiend.

I would actually prefer we use the display attribute that comes with the DOM

What I meant there was that we probably need to keep track of the last/previous value of the display attribute when we change it. For ex. if we hide a div which has been set to inline-block, we'll be setting display to none. When the user calls toggle or show again, we should probably make sure that the display attribute is set back to inline-block, instead of the regular block value. It's certainly likely that between the two calls, some other code changes that attribute. But that's how jQuery behaves. So I thought that might be the expected behavior from vanilla-js as well.

Bhashit avatar Nov 06 '17 05:11 Bhashit

When the user calls toggle or show again, we should probably make sure that the display attribute is set back to inline-block, instead of the regular block value. It's certainly likely that between the two calls, some other code changes that attribute. But that's how jQuery behaves.

Ah I misunderstood what you were talking about.

Could we stick that in the DOM too under a special data- attribute? Perhaps data-liftjs-previous-display-value? That would avoid having to track a var in JS space and still permit other JS that's being written to change how we behave when we act on the object.

farmdawgnation avatar Nov 06 '17 15:11 farmdawgnation

data-liftjs-previous-display-value sounds perfect. I thought about doing something like that, then thought that maybe we could get away without having to make that visible. But what you said makes more sense. The following part:

still permit other JS that's being written to change how we behave when we act on the object

Will go forward with that approach then.

Bhashit avatar Nov 06 '17 16:11 Bhashit