Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log(node.tagName);
}
if (!node['attrs']) return;
node.attrs.forEach(function(attr){
if (attr.name === 'script'){
var script = attr.value;
var nsFn = script.split('.');
attr.name = 'ns'
attr.value = nsFn[0];
node.attrs.push({name: 'fn', value: nsFn[1]});
}
});
}
walk(document, hasScript);
var serializer = new parse5.Serializer();
var refactoredHtml = serializer.serialize(document);
fs.writeFileSync(filename, refactoredHtml);
var parse5 = require('parse5')
var parser = new parse5.Parser();
var serializer = new parse5.Serializer();
//https://github.com/exolution/xCube/blob/master/XParser.js
//Then feed it with an HTML document
//------------------------------------------
var expose = Date.now()
function log() {
if (avalon.config.debug) {
// http://stackoverflow.com/questions/8785624/how-to-safely-wrap-console-log
console.log.apply(console, arguments)
}
}
/**
* Creates a new object without a prototype. This object is useful for lookup without having to
* guard against prototypically inherited properties via hasOwnProperty.
*
* Related micro-benchmarks:
* - http://jsperf.com/object-create2
import { Parser, Serializer, TreeAdapters } from 'parse5';
// PRIVATE
import { getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
// PRIVATE
const parser = new Parser(TreeAdapters.htmlparser2);
// TODO(gdi2290): fix encodeHtmlEntities: true
const serializer = new Serializer(TreeAdapters.htmlparser2, { encodeHtmlEntities: true });
const treeAdapter = parser.treeAdapter;
export function isTag (tagName, node): boolean {
return node.type === 'tag' && node.name === tagName;
}
export function parseFragment (el: string): any {
return parser.parseFragment(el);
}
export function parseDocument (documentHtml: string): any {
if (documentHtml === undefined) {
throw new Error('parseDocument requires a document string');
}
if (typeof documentHtml !== 'string') {
throw new Error('parseDocument needs to be a string to be parsed correctly');
import {Parser, Serializer, TreeAdapters} from 'parse5';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
const parser = new Parser(TreeAdapters.htmlparser2);
// TODO(gdi2290): fix encodeHtmlEntities: true
const serializer = new Serializer(TreeAdapters.htmlparser2, { encodeHtmlEntities: true });
const treeAdapter = parser.treeAdapter;
export function isTag (tagName, node): boolean {
return node.type === 'tag' && node.name === tagName;
}
export function parseFragment (el: string): any {
return parser.parseFragment(el);
}
export function parseDocument (documentHtml: string): any {
if (documentHtml === undefined) {
throw new Error('parseDocument requires a document string');
}
if (typeof documentHtml !== 'string') {
throw new Error('parseDocument needs to be a string to be parsed correctly');
if (klass === namespace){
node.attrs.splice(index, 1);
console.log('removing class %s', klass);
return;
}
var classes = klass.split(/\s+/);
if (classes.indexOf(namespace) > -1){
classes.splice(classes.indexOf(namespace), 1);
console.log('updating class %s (%s) to remove %s: %s', klass, node.attrs[index].value, namespace, classes.join(' '));
node.attrs[index].value = classes.join(' ');
}
}
}
walk(document, dropNSFromClasses);
var serializer = new parse5.Serializer();
var refactoredHtml = serializer.serialize(document);
fs.writeFileSync(filename, refactoredHtml);
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var parse5 = require('parse5');
var parser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
var serializer = new parse5.Serializer(parse5.TreeAdapters.htmlparser2);
var treeAdapter = parser.treeAdapter;
var cssParse = require('css').parse;
var url = require('url');
var collection_1 = require('angular2/src/facade/collection');
var dom_adapter_1 = require('./dom_adapter');
var lang_1 = require('angular2/src/facade/lang');
var selector_1 = require('angular2/src/render/dom/compiler/selector');
var _attrToPropMap = {
'innerHtml': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};
var defDoc = null;
function _notImplemented(methodName) {
return new lang_1.BaseException('This method is not implemented in Parse5DomAdapter: ' + methodName);
}
var parse5 = require('parse5');
var parser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
var serializer = new parse5.Serializer(parse5.TreeAdapters.htmlparser2);
var treeAdapter = parser.treeAdapter;
var cssParse = require('css').parse;
var url = require('url');
import {List, MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {DomAdapter, setRootDomAdapter} from './dom_adapter';
import {BaseException, isPresent, isBlank, global} from 'angular2/src/facade/lang';
import {SelectorMatcher, CssSelector} from 'angular2/src/render/dom/compiler/selector';
var _attrToPropMap = {
'innerHtml': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};
var parse5 = require('parse5')
var parser = new parse5.Parser()
var serializer = new parse5.Serializer()
var loaderUtils = require('loader-utils')
module.exports = function (html) {
this.cacheable()
var query = loaderUtils.parseQuery(this.query)
var id = query.id
var tree = parser.parseFragment(html)
walk(tree, function (node) {
if (node.attrs) {
node.attrs.push({
name: id,
value: ''
})
}
})
return serializer.serialize(tree)
constructor(doc) {
this._doc = doc;
this._parser = new Parser();
this._ast = undefined;
this._css = '';
this._serializer = new parse5.Serializer();
this._rules = [];
}
function serialize(ast) {
var serializer = new parse5.Serializer();
return serializer.serialize(ast);
}