Let Me Tink About It
Let Me Tink About It

Reputation: 16132

Polymer 1.0: What native methods are available to event targets?

This documentation describes Polymer's event retargeting.

Following the documentation, I have obtained a "normalized event object" (NEO) using Polymer.dom(event).

Neither the event retargeting documentation nor the API documentation describes what native methods are available (like .getAttribute()). For an example, see Amit's answer to this question.

What native methods are available to this normalized event object? And where are they documented?

Upvotes: 1

Views: 400

Answers (2)

Let Me Tink About It
Let Me Tink About It

Reputation: 16132

Here is documentation on the DOM API that contains at least a partial list.

It includes the following.

Polymer.dom(parent).appendChild(node)
Polymer.dom(parent).insertBefore(node, beforeNode)
Polymer.dom(parent).removeChild(node)
Polymer.dom.flush()
Polymer.dom(parent).childNodes
Polymer.dom(node).parentNode
Polymer.dom(node).firstChild
Polymer.dom(node).lastChild
Polymer.dom(node).firstElementChild
Polymer.dom(node).lastElementChild
Polymer.dom(node).previousSibling
Polymer.dom(node).nextSibling
Polymer.dom(node).textContent
Polymer.dom(node).innerHTML
Polymer.dom(parent).querySelector(selector)
Polymer.dom(parent).querySelectorAll(selector)
Polymer.dom(contentElement).getDistributedNodes()
Polymer.dom(node).getDestinationInsertionPoints()
Polymer.dom(node).setAttribute(attribute, value)
Polymer.dom(node).removeAttribute(attribute)
Polymer.dom(node).classList

Upvotes: 0

Neil John Ramal
Neil John Ramal

Reputation: 3734

A normalized event object has only three properties listed: rootTarget, localTarget, and path. The first two are element/node objects while path is an array of nodes at which the event passes through. Your little snippet above would likely be solved by using either of the first two, but I'd suggest using localTarget instead since it's the retargeted one.

var obj = Polymer.dom(event).localTarget;
var arg = obj.getAttribute('data-foo'); // or obj.dataset.foo

Upvotes: 2

Related Questions