Skip to content

Commit

Permalink
more feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Oct 14, 2017
1 parent e71b84a commit 15cbdff
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/mixins/dir-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../utils/style-gather.html">
<link rel="import" href="../utils/resolve-url.html">
<link rel="import" href="property-accessors.html">

<script>
Expand All @@ -27,11 +25,13 @@
const DIR_INSTANCES = [];

/** @type {MutationObserver} */
let OBSERVER = null;
let observer = null;

let DOCUMENT_DIR = document.documentElement.getAttribute('dir');
let DOCUMENT_DIR = '';

let takeRecords = function(){};
function getRTL() {
DOCUMENT_DIR = document.documentElement.getAttribute('dir');
}

/**
* @param {!Polymer_DirMixin} instance Instance to set RTL status on
Expand Down Expand Up @@ -73,13 +73,10 @@
*/
Polymer.DirMixin = Polymer.dedupingMixin((base) => {

if (!OBSERVER) {
OBSERVER = new MutationObserver(updateDirection);
OBSERVER.observe(document.documentElement, {attributes: true, attributeFilter: ['dir']});
takeRecords = function() {
OBSERVER.takeRecords();
updateDirection();
};
if (!observer) {
getRTL();
observer = new MutationObserver(updateDirection);
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['dir']});
}

/**
Expand Down Expand Up @@ -142,8 +139,8 @@
/** @type {!Polymer_ElementMixin} */(elementBase).prototype.connectedCallback.call(this);
}
if (this.constructor.__activateDir) {
takeRecords();
DIR_INSTANCES.push(this);
getRTL();
setRTL(this);
}
}
Expand All @@ -154,7 +151,6 @@
/** @type {!Polymer_ElementMixin} */(elementBase).prototype.disconnectedCallback.call(this);
}
if (this.constructor.__activateDir) {
takeRecords();
const idx = DIR_INSTANCES.indexOf(this);
if (idx > -1) {
DIR_INSTANCES.splice(idx, 1);
Expand Down

0 comments on commit 15cbdff

Please sign in to comment.