This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom-element): patch customElement v1 APIs (#1133)
- Loading branch information
1 parent
60adc9c
commit 427705f
Showing
11 changed files
with
239 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
{ | ||
"path": "dist/zone.min.js", | ||
"checkTarget": true, | ||
"limit": 42050 | ||
"limit": 42500 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
module.exports = function (config) { | ||
require('./karma-build-jasmine.conf.js')(config); | ||
config.client.entrypoint = 'browser_es6_entry_point'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
module.exports = function (config) { | ||
require('./karma-dist-jasmine.conf.js')(config); | ||
require('./sauce.es6.conf')(config); | ||
config.client.entrypoint = 'browser_es6_entry_point'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Sauce configuration | ||
|
||
module.exports = function(config, ignoredLaunchers) { | ||
// The WS server is not available with Sauce | ||
config.files.unshift('test/saucelabs.js'); | ||
|
||
var basicLaunchers = { | ||
'SL_CHROME_66': {base: 'SauceLabs', browserName: 'chrome', version: '66'}, | ||
}; | ||
|
||
var customLaunchers = {}; | ||
if (!ignoredLaunchers) { | ||
customLaunchers = basicLaunchers; | ||
} else { | ||
Object.keys(basicLaunchers).forEach(function(key) { | ||
if (ignoredLaunchers | ||
.filter(function(ignore) { | ||
return ignore === key; | ||
}) | ||
.length === 0) { | ||
customLaunchers[key] = basicLaunchers[key]; | ||
} | ||
}); | ||
} | ||
|
||
config.set({ | ||
captureTimeout: 120000, | ||
browserNoActivityTimeout: 240000, | ||
|
||
sauceLabs: { | ||
testName: 'Zone.js', | ||
startConnect: false, | ||
recordVideo: false, | ||
recordScreenshots: false, | ||
options: { | ||
'selenium-version': '2.53.0', | ||
'command-timeout': 600, | ||
'idle-timeout': 600, | ||
'max-duration': 5400 | ||
} | ||
}, | ||
|
||
customLaunchers: customLaunchers, | ||
|
||
browsers: Object.keys(customLaunchers), | ||
|
||
reporters: ['dots', 'saucelabs'], | ||
|
||
singleRun: true, | ||
|
||
plugins: ['karma-*'] | ||
}); | ||
|
||
if (process.env.TRAVIS) { | ||
config.sauceLabs.build = | ||
'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; | ||
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; | ||
|
||
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
/* | ||
* check that document.registerElement(name, { prototype: proto }); | ||
* is properly patched | ||
*/ | ||
|
||
function customElementsSupport() { | ||
return 'registerElement' in document; | ||
} | ||
customElementsSupport.message = 'window.customElements'; | ||
|
||
describe('customElements', function() { | ||
const testZone = Zone.current.fork({ name: 'test' }); | ||
const bridge = { | ||
connectedCallback: () => {}, | ||
disconnectedCallback: () => {}, | ||
adoptedCallback: () => {}, | ||
attributeChangedCallback: () => {} | ||
}; | ||
|
||
class TestCustomElement extends HTMLElement { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
static get observedAttributes() { | ||
return ['attr1', 'attr2']; | ||
} | ||
|
||
connectedCallback() { | ||
return bridge.connectedCallback(); | ||
} | ||
|
||
disconnectedCallback() { | ||
return bridge.disconnectedCallback(); | ||
} | ||
|
||
attributeChangedCallback(attrName, oldVal, newVal) { | ||
return bridge.attributeChangedCallback(attrName, oldVal, newVal); | ||
} | ||
|
||
adoptedCallback() { | ||
return bridge.adoptedCallback(); | ||
} | ||
} | ||
|
||
testZone.run(() => { | ||
customElements.define('x-test', TestCustomElement); | ||
}); | ||
|
||
let elt; | ||
|
||
beforeEach(() => { | ||
bridge.connectedCallback = () => {}; | ||
bridge.disconnectedCallback = () => {}; | ||
bridge.attributeChangedCallback = () => {}; | ||
bridge.adoptedCallback = () => {}; | ||
}); | ||
|
||
afterEach(() => { | ||
if (elt) { | ||
document.body.removeChild(elt); | ||
elt = null; | ||
} | ||
}); | ||
|
||
it('should work with connectedCallback', function(done) { | ||
bridge.connectedCallback = function() { | ||
expect(Zone.current.name).toBe(testZone.name); | ||
done(); | ||
}; | ||
|
||
elt = document.createElement('x-test'); | ||
document.body.appendChild(elt); | ||
}); | ||
|
||
it('should work with disconnectedCallback', function(done) { | ||
bridge.disconnectedCallback = function() { | ||
expect(Zone.current.name).toBe(testZone.name); | ||
done(); | ||
}; | ||
|
||
elt = document.createElement('x-test'); | ||
document.body.appendChild(elt); | ||
document.body.removeChild(elt); | ||
elt = null; | ||
}); | ||
|
||
it('should work with attributeChanged', function(done) { | ||
bridge.attributeChangedCallback = function(attrName, oldVal, newVal) { | ||
expect(Zone.current.name).toBe(testZone.name); | ||
expect(attrName).toEqual('attr1'); | ||
expect(newVal).toEqual('value1'); | ||
done(); | ||
}; | ||
|
||
elt = document.createElement('x-test'); | ||
document.body.appendChild(elt); | ||
elt.setAttribute('attr1', 'value1'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import './browser/custom-element.spec'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
427705f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I need this fix. Can I hope for a new release soon? Thank you!