Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /*
2 * Copyright 2012, Mozilla Foundation and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
17 'use strict';
19 var util = require('../util/util');
21 /**
22 * Several converters are just data.toString inside a 'p' element
23 */
24 function nodeFromDataToString(data, conversionContext) {
25 var node = util.createElement(conversionContext.document, 'p');
26 node.textContent = data.toString();
27 return node;
28 }
30 exports.items = [
31 {
32 item: 'converter',
33 from: 'string',
34 to: 'dom',
35 exec: nodeFromDataToString
36 },
37 {
38 item: 'converter',
39 from: 'number',
40 to: 'dom',
41 exec: nodeFromDataToString
42 },
43 {
44 item: 'converter',
45 from: 'boolean',
46 to: 'dom',
47 exec: nodeFromDataToString
48 },
49 {
50 item: 'converter',
51 from: 'undefined',
52 to: 'dom',
53 exec: function(data, conversionContext) {
54 return util.createElement(conversionContext.document, 'span');
55 }
56 },
57 {
58 item: 'converter',
59 from: 'number',
60 to: 'string',
61 exec: function(data) { return '' + data; }
62 },
63 {
64 item: 'converter',
65 from: 'boolean',
66 to: 'string',
67 exec: function(data) { return '' + data; }
68 },
69 {
70 item: 'converter',
71 from: 'undefined',
72 to: 'string',
73 exec: function(data) { return ''; }
74 }
75 ];