Skip to content

document.uniqueID always returns unique id#1441

Merged
dfilatov merged 2 commits intobem:v4from
vsesh:v4
Oct 25, 2016
Merged

document.uniqueID always returns unique id#1441
dfilatov merged 2 commits intobem:v4from
vsesh:v4

Conversation

@vsesh
Copy link
Contributor

@vsesh vsesh commented Oct 24, 2016

Fix #1440

Copy link
Member

@veged veged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block supposed to use in "vanilla.js" runtime that lacks document object — so let's do the check in more safe cross-engine way

identify = function(obj) {
if((typeof obj === 'object' && obj !== null) || typeof obj === 'function') {
var key = 'uniqueID' in obj?
var key = 'uniqueID' in obj && obj !== document ?
Copy link
Member

@dfilatov dfilatov Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a better way:

var key;
if('uniqueID' in obj) {
    obj === global.document && (obj = obj.documentElement); // global should point to this.global inside module closure
    key = 'uniqueID';
} else {
    key = expando;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a bonus, you won't have to check browser environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 62.539% when pulling b3c90a5 on vsesh:v4 into 2c32fef on bem:v4.

@dfilatov dfilatov merged commit 82e8ef7 into bem:v4 Oct 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants