You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+17
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,23 @@ The intent is to wrap all the DOM objects that interact with the DOM tree. For t
88
88
89
89
There are bound to be cases where we haven't done the wrapping for you. In those cases you can use `wrap` to create a wrapper of a native object, or `unwrap` to get the underlying native object from a wrapper. These two functions are available on the `ShadowDOMPolyfill` object.
90
90
91
+
ex:
92
+
93
+
wrap(document).addEventListener(...)
94
+
unwrap(div).firstChild instanceof HTMLElement
95
+
96
+
If you plan to work with elements that need to be wrapped over and over, try passing a wrapped version of the element into an immediately-invoked function expression.
97
+
98
+
(function(document) {
99
+
100
+
// Now a library like jQuery can add
101
+
// listeners to the wrapped document
102
+
$(document).on('click', function(e) {
103
+
console.log('Clicked on', e.target);
104
+
});
105
+
106
+
})(wrap(document));
107
+
91
108
#### Event Retargetting
92
109
93
110
An important aspect of the shadow DOM is that events are retargetted to never expose the shadow DOM to the light DOM. For example.
0 commit comments