Skip to content

Commit

Permalink
remove polymer-element import
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Jun 29, 2017
1 parent 28569ba commit c49f1a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
30 changes: 9 additions & 21 deletions iron-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ <h2>Hello world!</h2>
(() => {
'use strict';

const contentHostGenerator = new Polymer.ScopingHostGenerator('iron-overlay-content-host');
const _contentHostGenerator = new ScopingHostGenerator('iron-overlay-content-host');
const _sharedListener = new SharedEventListener();

class IronOverlay extends Polymer.Element {

Expand Down Expand Up @@ -184,19 +185,6 @@ <h2>Hello world!</h2>
_restoreFocusNode: {
type: Object,
value: null
},

/**
* A shared event listener to handle interactions like click or keydown.
* The last overlay opened will be the last to listen for events, but should
* be the first to handle the event. The shared event listener allows this, delegating
* the handling of the event to the last one listening for it.
* @protected
*/
_sharedListener: {
type: Object,
readOnly: true,
value: new Polymer.SharedEventListener()
}
};
}
Expand Down Expand Up @@ -272,7 +260,7 @@ <h2>Hello world!</h2>
cancelable: true,
bubbles: true,
composed: true,
detail : event
detail: event
});
this.dispatchEvent(cancelEvent);
if (!cancelEvent.defaultPrevented) {
Expand All @@ -288,11 +276,11 @@ <h2>Hello world!</h2>
*/
_toggleListeners() {
if (this.opened) {
this._sharedListener.listen('click', this, '_captureOutsideClick');
this._sharedListener.listen('keydown', this, '_captureEscapeKey');
_sharedListener.listen('click', this, '_captureOutsideClick');
_sharedListener.listen('keydown', this, '_captureEscapeKey');
} else {
this._sharedListener.unlisten('click', this);
this._sharedListener.unlisten('keydown', this);
_sharedListener.unlisten('click', this);
_sharedListener.unlisten('keydown', this);
}
}

Expand All @@ -318,7 +306,7 @@ <h2>Hello world!</h2>
if (contentTemplate) {
// Scope styles by creating an intermediate element's shadowRoot.
if (contentTemplate.content.querySelector('style')) {
const el = contentHostGenerator.generate(contentTemplate);
const el = _contentHostGenerator.generate(contentTemplate);
renderer.appendChild(el);
this._setContentHost(el.shadowRoot);
} else {
Expand Down Expand Up @@ -484,7 +472,7 @@ <h2>Hello world!</h2>
cancelable: false,
bubbles: true,
composed: true,
detail : this.closingReason
detail: this.closingReason
}));
this._ensureDetached();
}
Expand Down
5 changes: 1 addition & 4 deletions scoping-host-generator.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<link rel="import" href="../polymer/polymer-element.html">

<script>
(() => {
'use strict';

/**
* ScopingHostGenerator allows to create an element with a shadow root.
* The generated element can be used to scope styles by inserting content
* in its shadowRoot.
*/
Polymer.ScopingHostGenerator = class ScopingHostGenerator {
window.ScopingHostGenerator = class ScopingHostGenerator {
/**
* @type {!string} hostTagName
*/
Expand Down
13 changes: 3 additions & 10 deletions shared-event-listener.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,20 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<link rel="import" href="../polymer/polymer-element.html">

<script>
(() => {
'use strict';

/**
* SharedEventListener allows to register callback for an event on document
* ensuring that the last registered callback is the one called.
* SharedEventListener allows to register callback for an event on
* document ensuring that the last registered callback is the one called.
* e.g. `node1`, `node2`, then `node3` listen for `click` event -> `node3`
* is the one to handle it.
*/
Polymer.SharedEventListener = class SharedEventListener {

window.SharedEventListener = class SharedEventListener {
constructor() {
this._events = {};
this._handleEvent = this._handleEvent.bind(this);
}

/**
* Expects a callback that returns true when it handles the event, false
* to allow the event to be handled by the next listener.
Expand All @@ -44,7 +39,6 @@
callback: callback
});
}

unlisten(eventName, listener) {
if (!this._events[eventName]) {
return;
Expand All @@ -60,7 +54,6 @@
});
}
}

_handleEvent(event) {
const handlers = this._events[event.type];
let i = handlers.length - 1;
Expand Down

0 comments on commit c49f1a9

Please sign in to comment.