A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AngleSharp/AngleSharp.Js/issues/31 below:

Handling of old/poorly formed Javascript window.location = url · Issue #31 · AngleSharp/AngleSharp.Js · GitHub

Right now, there is an issue in the handling of the window.location with regards to handling the old and incorrect, but still commonly used javascript syntax of setting the window.location to a url instead of referencing it as window.location.href = url.

Non-Working:

Working:

window.location.href` = "/"

Since I am unaware of a way to have a property return one datatype but accept another in the setter, n theory, using the object type as the property type the code in Window.cs could be modified from:

        /// <summary>
        /// Gets the location of the currently contained document.
        /// </summary>
        public ILocation Location
        {
            get { return Document.Location; }
        }

to the less elegant, but functional:

         /// <summary>
        /// Gets the location of the currently contained document.
        /// </summary>
        public object Location
        {
            get { return Document.Location; }
	    set
		{
			String locationAsUrl = value.ToString();
			// probably need to validate the resulting string
			if (validateUrl(locationAsUrl))
			{
				Document.Location.Href = locationAsUrl;
			}
		}
        }

A big weakness here is that it would require typecasting the returned object to an ILocation for any strongly typed code not using the var notation.

Your thoughts ?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4