Skip to content

Commit 0cbfe05

Browse files
committed
simplify _.inDoc fix and remove unit test patch for phantomjs
1 parent f910124 commit 0cbfe05

File tree

6 files changed

+9
-41
lines changed

6 files changed

+9
-41
lines changed

gruntfile.js

-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ module.exports = function (grunt) {
4242
files: [
4343
'test/unit/lib/jquery.js',
4444
'src/**/*.js',
45-
'test/unit/lib/indoc_patch.js',
4645
'test/unit/specs/**/*.js'
4746
],
4847
preprocessors: {
4948
'src/**/*.js': ['commonjs'],
50-
'test/unit/lib/indoc_patch.js': ['commonjs'],
5149
'test/unit/specs/**/*.js': ['commonjs']
5250
},
5351
singleRun: true
@@ -64,7 +62,6 @@ module.exports = function (grunt) {
6462
reporters: ['progress', 'coverage'],
6563
preprocessors: {
6664
'src/**/*.js': ['commonjs', 'coverage'],
67-
'test/unit/lib/indoc_patch.js': ['commonjs'],
6865
'test/unit/specs/**/*.js': ['commonjs']
6966
},
7067
coverageReporter: {

src/util/dom.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ var config = require('../config')
22

33
/**
44
* Check if a node is in the document.
5-
* Note: document.documentElement.contains should work here but doesn't seem to
6-
* work properly in phantom.js making unit testing difficult.
5+
* Note: document.documentElement.contains should work here
6+
* but always returns false for comment nodes in phantomjs,
7+
* making unit tests difficult. This is fixed byy doing the
8+
* contains() check on the node's parentNode instead of
9+
* the node itself.
710
*
811
* @param {Node} node
912
* @return {Boolean}
@@ -14,13 +17,10 @@ var doc =
1417
document.documentElement
1518

1619
exports.inDoc = function (node) {
17-
var adown = doc.nodeType === 9 ? doc.documentElement : doc
18-
var bup = node && node.parentNode
19-
return doc === bup || !!( bup && bup.nodeType === 1 && (
20-
adown.contains
21-
? adown.contains( bup )
22-
: doc.compareDocumentPosition && doc.compareDocumentPosition( bup ) & 16
23-
));
20+
var parent = node && node.parentNode
21+
return doc === node ||
22+
doc === parent ||
23+
!!(parent && parent.nodeType === 1 && (doc.contains(parent)))
2424
}
2525

2626
/**

test/unit/lib/indoc_patch.js

-23
This file was deleted.

test/unit/specs/directives/component_spec.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// patch inDoc
2-
require('../../lib/indoc_patch')
31
var _ = require('../../../../src/util')
42
var Vue = require('../../../../src/vue')
53

test/unit/specs/directives/repeat_spec.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// patch inDoc
2-
require('../../lib/indoc_patch')
31
var _ = require('../../../../src/util')
42
var Vue = require('../../../../src/vue')
53

test/unit/specs/misc_spec.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// patch inDoc
2-
require('../lib/indoc_patch')
31
// test cases for edge cases & bug fixes
42
var Vue = require('../../../src/vue')
53

0 commit comments

Comments
 (0)