-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add detection of popular frameworks, with tests to validate (#171)
* add detection of popular frameworks, with tests to validate * fixed problem with url subpath that broke tests in old safari versions, and moved framework-detection lib to aggregator to ensure that the dom had been populated before execution * change architecture to fix broken tests * update test to run on more platforms, and remove code that may not be universally supported
- Loading branch information
1 parent
62a3223
commit d173ed0
Showing
29 changed files
with
106,067 additions
and
3 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
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,53 @@ | ||
var FRAMEWORKS = { | ||
REACT: 'React', | ||
ANGULAR: 'Angular', | ||
ANGULARJS: 'AngularJS', | ||
BACKBONE: 'Backbone', | ||
EMBER: 'Ember', | ||
VUE: 'Vue', | ||
METEOR: 'Meteor', | ||
ZEPTO: 'Zepto', | ||
JQUERY: 'Jquery' | ||
} | ||
|
||
function getFrameworks() { | ||
var frameworks = [] | ||
try { | ||
if (detectReact()) frameworks.push(FRAMEWORKS.REACT) | ||
if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS) | ||
if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR) | ||
if (window.Backbone) frameworks.push(FRAMEWORKS.BACKBONE) | ||
if (window.Ember) frameworks.push(FRAMEWORKS.EMBER) | ||
if (window.Vue) frameworks.push(FRAMEWORKS.VUE) | ||
if (window.Meteor) frameworks.push(FRAMEWORKS.METEOR) | ||
if (window.Zepto) frameworks.push(FRAMEWORKS.ZEPTO) | ||
if (window.jQuery) frameworks.push(FRAMEWORKS.JQUERY) | ||
return frameworks | ||
} catch (err) { | ||
// not supported? | ||
} | ||
} | ||
|
||
function detectReact() { | ||
if (!!window.React || !!window.ReactDOM || !!window.ReactRedux) return true | ||
if (document.querySelector('[data-reactroot], [data-reactid]')) return true | ||
var divs = document.querySelectorAll('body > div') | ||
for (var i = 0; i < divs.length; i++) { | ||
if (Object.keys(divs[i]).indexOf('_reactRootContainer') >= 0) return true | ||
} | ||
return false | ||
} | ||
|
||
function detectAngularJs() { | ||
if (window.angular) return true | ||
if (document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]')) return true | ||
if (document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]')) return true | ||
return false | ||
} | ||
|
||
function detectAngular() { | ||
if (window.hasOwnProperty('ng') && window.ng.hasOwnProperty('coreTokens') && window.ng.coreTokens.hasOwnProperty('NgZone')) return true | ||
return !!document.querySelectorAll('[ng-version]').length | ||
} | ||
|
||
module.exports = getFrameworks() |
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
14 changes: 14 additions & 0 deletions
14
tests/assets/frameworks/angular/simple-app/assets/shipping.json
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,14 @@ | ||
[ | ||
{ | ||
"type": "Overnight", | ||
"price": 25.99 | ||
}, | ||
{ | ||
"type": "2-Day", | ||
"price": 9.99 | ||
}, | ||
{ | ||
"type": "Postal", | ||
"price": 2.99 | ||
} | ||
] |
Binary file not shown.
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,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
{init} | ||
{loader} | ||
{config} | ||
<meta charset="utf-8"/> | ||
<title>Angular Getting Started</title> | ||
<base href ="./index.html"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"/> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico"/> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/> | ||
<link rel="stylesheet" href="styles.css"></head> | ||
<body> | ||
<app-root></app-root> | ||
<script src="runtime-es5.js"></script><script src="polyfills-es5.js"></script><script src="vendor-es5.js"></script><script src="main-es5.js" ></script> | ||
</body> | ||
</html> |
Oops, something went wrong.