3 ms·
Totally agree with declarative code that can be overridden with "proper" code. However in this particular instance, the declarative API in HTML for getting a re
by malandrew 12y ago
Totally agree with declarative code that can be overridden with "proper" code. However in this particular instance, the declarative API in HTML for getting a resource at a particular URI already exists in the form of the "href" property. I don't understand what AJAX here adds at all, since it's not congruous with the semantics of the term AJAX -> "Asynchronous Javascript and XML". There is no javascript there. There's no notion of "asynchronicity" in a declarative interface since async connotes flow control. And the XML (part) used to refer to the original data structure format that was retrieved, whereas most people these days use JSON and even this example uses JSON.
It's not even clear from this example, what is done with the JSON data fetched here. It's not assigned to a variable or returned by a callback. The script below the element in fact uses globals to access the code, since that is basically what `document.querySelector` does. Putting stuff in the DOM is the equivalent of saving all your variables on the window object and then accessing them with `window.myDomElement`, but in a more verbose, indirect and non-performant way.
var ajax = document.querySelector('polymer-ajax');
ajax.addEventListener("polymer-response", function(event) {
assert.isTrue(event.detail.response.feed.entry.length > 0);
done();
});
Furthermore, I noticed in some of the markup elements, the addition of a "url" property. How does "url" differ from "href", especially, when all the examples I saw had URIs pointing to *.html hypertext documents. Is "url" a new property that exists in a standard somewhere? If not, I was under the impression that non-standard HTML properties are supposed to be prefixed.