| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The Polymer Authors. All rights reserved. | 2 * Copyright 2013 The Polymer Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style | 3 * Use of this source code is governed by a BSD-style |
| 4 * license that can be found in the LICENSE file. | 4 * license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 module.exports = function(grunt) { | 6 module.exports = function(grunt) { |
| 7 ShadowDOMPolyfill = [ | 7 // Recursive module builder: |
| 8 'sidetable.js', | 8 var path = require('path'); |
| 9 'wrappers.js', | 9 function readManifest(filename, modules) { |
| 10 'wrappers/events.js', | 10 modules = modules || []; |
| 11 'wrappers/NodeList.js', | 11 var lines = grunt.file.readJSON(filename); |
| 12 'wrappers/Node.js', | 12 var dir = path.dirname(filename); |
| 13 'querySelector.js', | 13 lines.forEach(function(line) { |
| 14 'wrappers/node-interfaces.js', | 14 var fullpath = path.join(dir, line); |
| 15 'wrappers/CharacterData.js', | 15 if (line.slice(-5) == '.json') { |
| 16 'wrappers/Element.js', | 16 // recurse |
| 17 'wrappers/HTMLElement.js', | 17 readManifest(fullpath, modules); |
| 18 'wrappers/HTMLContentElement.js', | 18 } else { |
| 19 'wrappers/HTMLShadowElement.js', | 19 modules.push(fullpath); |
| 20 'wrappers/HTMLTemplateElement.js', | 20 } |
| 21 'wrappers/HTMLUnknownElement.js', | 21 }); |
| 22 'wrappers/generic.js', | 22 return modules; |
| 23 'wrappers/ShadowRoot.js', | 23 } |
| 24 'ShadowRenderer.js', | |
| 25 'wrappers/Document.js', | |
| 26 'wrappers/Window.js', | |
| 27 'wrappers/MutationObserver.js', | |
| 28 'wrappers/override-constructors.js' | |
| 29 ]; | |
| 30 ShadowDOMPolyfill = ShadowDOMPolyfill.map(function(p) { | |
| 31 return '../../../third_party/polymer/ShadowDOM/src/' + p; | |
| 32 }); | |
| 33 | 24 |
| 34 // Apply partial patch from Polymer/Platform, dart2js, CSS | 25 // Karma setup: |
| 35 // polyfill from platform and dart2js CSS patches: | |
| 36 ShadowDOMPolyfill.unshift( | |
| 37 '../lib/src/platform/patches-shadowdom-polyfill-before.js' | |
| 38 ); | |
| 39 ShadowDOMPolyfill.push( | |
| 40 '../lib/src/platform/patches-shadowdom-polyfill.js', | |
| 41 '../lib/src/platform/platform-init.js', | |
| 42 '../lib/src/platform/ShadowCSS.js', | |
| 43 '../lib/src/platform/patches-shadow-css.js' | |
| 44 ); | |
| 45 | |
| 46 // Only load polyfill if not natively present. | |
| 47 ConditionalShadowDOM = [].concat( | |
| 48 'build/if-poly.js', | |
| 49 ShadowDOMPolyfill, | |
| 50 'build/end-if.js' | |
| 51 ); | |
| 52 | |
| 53 // karma setup | |
| 54 var browsers; | 26 var browsers; |
| 55 (function() { | 27 (function() { |
| 56 try { | 28 try { |
| 57 var config = grunt.file.readJSON('local.json'); | 29 var config = grunt.file.readJSON('local.json'); |
| 58 if (config.browsers) { | 30 if (config.browsers) { |
| 59 browsers = config.browsers; | 31 browsers = config.browsers; |
| 60 } | 32 } |
| 61 } catch (e) { | 33 } catch (e) { |
| 62 var os = require('os'); | 34 var os = require('os'); |
| 63 browsers = ['Chrome', 'Firefox']; | 35 browsers = ['Chrome', 'Firefox']; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 80 browsers: browsers, | 52 browsers: browsers, |
| 81 reporters: ['crbot'], | 53 reporters: ['crbot'], |
| 82 logLevel: 'OFF' | 54 logLevel: 'OFF' |
| 83 }, | 55 }, |
| 84 ShadowDOM: { | 56 ShadowDOM: { |
| 85 browsers: browsers | 57 browsers: browsers |
| 86 } | 58 } |
| 87 }, | 59 }, |
| 88 concat: { | 60 concat: { |
| 89 ShadowDOM: { | 61 ShadowDOM: { |
| 90 src: ConditionalShadowDOM, | 62 src: readManifest('build.json'), |
| 91 dest: '../lib/shadow_dom.debug.js', | 63 dest: '../lib/shadow_dom.debug.js', |
| 92 nonull: true | 64 nonull: true |
| 93 } | 65 } |
| 94 }, | 66 }, |
| 95 uglify: { | 67 uglify: { |
| 96 ShadowDOM: { | 68 ShadowDOM: { |
| 97 options: { | 69 options: { |
| 98 compress: { | 70 compress: { |
| 99 // TODO(sjmiles): should be false by default (?) | 71 // TODO(sjmiles): should be false by default (?) |
| 100 // https://github.com/mishoo/UglifyJS2/issues/165 | 72 // https://github.com/mishoo/UglifyJS2/issues/165 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 grunt.loadNpmTasks('grunt-contrib-yuidoc'); | 105 grunt.loadNpmTasks('grunt-contrib-yuidoc'); |
| 134 grunt.loadNpmTasks('grunt-karma-0.9.1'); | 106 grunt.loadNpmTasks('grunt-karma-0.9.1'); |
| 135 | 107 |
| 136 // tasks | 108 // tasks |
| 137 grunt.registerTask('default', ['concat', 'uglify']); | 109 grunt.registerTask('default', ['concat', 'uglify']); |
| 138 grunt.registerTask('minify', ['concat', 'uglify']); | 110 grunt.registerTask('minify', ['concat', 'uglify']); |
| 139 grunt.registerTask('docs', ['yuidoc']); | 111 grunt.registerTask('docs', ['yuidoc']); |
| 140 grunt.registerTask('test', ['karma:ShadowDOM']); | 112 grunt.registerTask('test', ['karma:ShadowDOM']); |
| 141 grunt.registerTask('test-buildbot', ['karma:buildbot']); | 113 grunt.registerTask('test-buildbot', ['karma:buildbot']); |
| 142 }; | 114 }; |
| 143 | |
| OLD | NEW |