var map = new WeakMap();
var someEl =
document.getElementById('someEl');
map.set(someEl, {foo: 'bar'});
if (map.has(document.getElementById('someEl') {
map.get(someEl).foo; // bar
}
scope.name = 'Ray';
scope.$watch('name', function(newV, oldV) {
console.log('old name: ' + oldV);
console.log('new name: ' + newV);
});
scope.name = "Ray";
Object.observe(scope, function(change) {
if (change.name === 'name') {
console.log('old name: ' +
change.oldValue);
console.log('new value: ' +
change.object[change.name]);
}
});
var callback = function(records) { var record = records[0]; // for demo simplicity only var added = record.addedNodes;
if (added.length) { var newTags = 0; for (var i = 0; i < added.length; i++) { if (added[i].className.indexOf('tag') >= 0) { newTags++; } }
if (newTags) { alert(newTags + " new tags added."); } } };
var observer = new MutationObserver(callback); observer.observe(tagsContainerEl, {childList: true});
<template>
<div>hi there</div>
<div>you can't see me right now</div>
<blink>luckily for you</blink>
</template>
// Grab the <link> that imports the licensing blurb var licensingLink = document.getElementById('licenseLink');
// Grab the relevant content from the imported doc
var content = licensingLink.import.getElementById('license');
// Append the content to our doc document.body.appendChild(content);
<my-custom-element></my-custom-element>
<foo-bar> <!-- unresolved content --> </foo-bar> <script> document.registerElement('foo-bar');
</script>
<video is="frame-grabber" src="somevideo.mp4">
</video> var frameGrabber = document.createElement('video', 'frame-grabber'); frameGrabber.prototype.grab = function() { // grab current frame & do something w/ it }
<blink-is-back>
Bring back the blink tag!
</blink-is-back>
<blink-is-back>
<div style="text-decoration: line-through;">
Bring back the blink element!
</div>
<div>But seriously, don't make text blink.</div>
</blink-is-back>
<file-input class="btn btn-primary" extensions='["jpeg", "jpg"]' minSize="500000" maxSize="3000000"> <span class="glyphicon glyphicon-file"></span>
Select a file </file-input>
<form is="ajax-form" method="POST" action="form/handler" headers='{"X-Cust-Header": "FooBar"}'> <input type="text" name="fullname" required>
<input type="submit"> </form>
form.addEventListener('submitted',
function(e) {
if (event.detail.status > 299) {
// submit may have failed
}
}
);
form.addEventListener('invalid',
function(e) {
e.detail.forEach(function(badEl) {
// do something w/ invalid element
});
}
);