Skip to content

Commit

Permalink
As per the API, set "attached" after attachedCallback() completes, no…
Browse files Browse the repository at this point in the history
…t before.

Refs #385, fixes ibm-js/deliteful#538, refs ibm-js/deliteful#539.
  • Loading branch information
wkeese committed Mar 30, 2015
1 parent bca1479 commit ab40ae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions Bidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ define([
textDir: "",

/**
* Get the direction setting for the page itself, or if `has("inherited-dir")` is defined, then
* for the dir setting inherited from any ancestor node.
* Return the direction setting for the page itself, or if `has("inherited-dir")` is defined and the widget is
* attached to the page, then return the dir setting inherited from any ancestor node.
* @returns {string} "ltr" or "rtl"
* @protected
*/
getInheritedDir: function () {
if (this.attached && has("inherited-dir")) {
return window.getComputedStyle(this, null).direction;
}
return this.ownerDocument.body.dir || this.ownerDocument.documentElement.dir || "ltr";
return this._inheritedDir || this.ownerDocument.body.dir || this.ownerDocument.documentElement.dir || "ltr";
},

attachedCallback: function () {
if (has("inherited-dir")) {
// Now that the widget is attached to the DOM, need to retrigger computation of effectiveDir.
this._inheritedDir = window.getComputedStyle(this, null).direction;
this.notifyCurrentValue("dir");
this.deliver();
}
Expand Down
4 changes: 2 additions & 2 deletions CustomElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ define([
// prematurely in the programmatic case (i.e. calling it before user parameters have been applied).
this.deliver();

this.attached = true;

// Protect against repeated calls.
this._realAttachedCallback = this.attachedCallback;
this.attachedCallback = nop;
Expand All @@ -252,6 +250,8 @@ define([
}
},
after: function () {
this.attached = true;

this.emit("customelement-attached", {
bubbles: false,
cancelable: false
Expand Down

0 comments on commit ab40ae4

Please sign in to comment.