GithubHelp home page GithubHelp logo

Comments (10)

erik-kallen avatar erik-kallen commented on June 3, 2024

This is from Script#. I guess the reason is that the type of the property, when returned, is a Location object, but when you set it you need to set it to a string. I can add a SetLocation method that does this.

from saltarellecompiler.

mattleibow avatar mattleibow commented on June 3, 2024

Or, you can add a method:

[ScriptSkip]
public static Location FromUrl(string url)
{
    return null;
}

so that we can do something like this:

Window.Location = Location.FromUrl("www.google.com");

The [ScriptSkip] attribute changes it to be:

window.location = "www.google.com"

from saltarellecompiler.

erik-kallen avatar erik-kallen commented on June 3, 2024

I'm not too happy about this model because it would also allow you to do

var l = Location.FromUrl("www.google.com/?q=abc");
string query = l.query;

from saltarellecompiler.

mattleibow avatar mattleibow commented on June 3, 2024

What about this:

Window.Location.Assign("www.google.com");

it exists

from saltarellecompiler.

erik-kallen avatar erik-kallen commented on June 3, 2024

Still the same modelling problem. What should this do:

var l = Window.Location;
l.Assign('www.google.com')

from saltarellecompiler.

mattleibow avatar mattleibow commented on June 3, 2024

It seems to work fine. Both will take you to Google.

from saltarellecompiler.

erik-kallen avatar erik-kallen commented on June 3, 2024

Depends on how you implement the method. The possibilities are:

[InlineCode("window.location = {url}")] Assign(string url)

which seems wrong to me (affecting static state in an instance method), and

[InlineCode("{this} = {url}")] Assign(string url)

which looks better, but obviously doesn't work in many cases.

from saltarellecompiler.

mattleibow avatar mattleibow commented on June 3, 2024

It already exists in the Location object.
And, this is how the JS works now:

var loc = window.location;
loc.assign('http://www.google.com');

If you want to do a C# logic, how will this work?
Updating location (or loc in this case) still navigates the page.

from saltarellecompiler.

erik-kallen avatar erik-kallen commented on June 3, 2024

Sorry, I have misunderstood everything. I thought you meant a new method, but now I see that it is already there. I don't know the entire DOM API.

from saltarellecompiler.

erik-kallen avatar erik-kallen commented on June 3, 2024

Added Window.SetLocation in 1.3.0

from saltarellecompiler.

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.