Modifying Text Nodes in JavaScript

Properties

  • Data
  • Length

Methods

  • appendData(String)
  • deleteData(start, length)
  • insertData(start, string)
  • replaceData(start, length, string)
  • splitText(start)
  • substringData(start, length)

Length

Length property is used to access the length of Text which indicates the number of characters it contains.

Syntax:- TextNode.length

Data

Data property is used to set or return the value of a text node and comment node objects.

Syntax: –
Sets
TextNode.data = value
Returns
TextNode.data

Ex:- TextNode.data = “Hello DevOpsSchool”;

appendData(String)

This method is used to append the passed string to the end of the text node and comment node.

Syntax: –
TextNode.appendData(String);

Ex: –
TextNode.appendData(“Hello DevOpsSchool”);

deleteData(start, length)

This method is used to delete or remove text content from a text node and comment node. It deletes the specified length of characters starting from index defined in start.

Syntax:-
TextNode.deleteData(start, length);

Ex: –
TextNode.deleteData(0, 5);

insertData(start, string)

This method is used to insert text content to text node and comment node. It inserts the value in string, starting at the character index specified in start.

Syntax:-
TextNode.insertData(start, string)

Ex: –
TextNode.insertData(3, “Hello”)

replaceData(start, length, string)

This method is used to replace text content of text node and comment node. It inserts the value in string, starting at the character index specified in start.

Syntax:-
TextNode.replaceData(start, length, string)

Ex: –
TextNode.replaceData(0, 4, “Hello”)

splitText(start)

The splitText(start) method breaks the Text node into two nodes at the specified start index, keeping both nodes in the tree as siblings. It returns right side of the split in a new text node and leaves the left side in the original.

Syntax: –
var rightSide = TextNode.splitText(start)

Ex: –
var rightSide = TextNode.splitText(5)

substringData(start, length)

It returns the part of the current element’s (TextNode and CommentNode) text content from the specified position with the specified length.

Syntax:-
TextNode.substringData(start, length)

Ex: –
TextNode.substringData(2, 5);

Tagged : / /

error in ./resources/assets/sass/app.scss

If you are getting this error (error in ./resources/assets/sass/app.scss) in Node module please follow some steps which is have mentioned in the following

Error:-

Many of you get this error when you did not change anything in app.scss, but when I run npm run watch I get the following errors:

 error  in ./resources/sass/app.scss                                                                      

Module build failed (from ./node_modules/sass-loader/lib/loader.js):                                      
Unsupported operation: Cannot extract a file path from a URI with a fragment component                    

@ ./resources/sass/app.scss 2:14-254                                                                     

    Asset      Size   Chunks             Chunk Names                                                     
/js/app.js  2.46 MiB  /js/app  [emitted]  /js/app                                                         

ERROR in ./resources/sass/app.scss                                                                        
Module build failed (from ./node_modules/css-loader/index.js):                                            
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):                    

undefined                                                                                                 
      ^                                                                                                  
      Join(null, "variables"): part 0 was null, but part 1 was not.                                       
@import 'variables';                                                                                      
        ^^^^^^^^^^^                                                                                       
  stdin 2:9  root stylesheet                                                                              
      in C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\resources\sass\app.scss (line 2, column 9)           
    at runLoaders (C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\webpack\lib\NormalModule.js:30
    at C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\LoaderRunner.js:364:11  
    at C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\LoaderRunner.js:230:18  
    at context.callback (C:\Users\TAQI VAHEED\Desktop\#Coding\resPro\node_modules\loader-runner\lib\Loader
13)

Solution:-

The main issue which we have found that is related to dart-sass being used instead of node-sass with laravel

You have to just follow one step:-

Step 1:- You have to run this Command and all the things will solve .

npm install node-sass

Tagged : / / / / / / / / / /

‘cross-env’ is not recognized as an internal or external command, operable program or batch file.

Hey if you are getting some error like (‘cross-env’ is not recognized as an internal or external command, operable program or batch file.) in your Node please follow the steps which i have mentioned in following:-

You need to make cross-env working globally instead of having it in the project.

Step 1:- remove node_modules folder

Step 2:-  run this Command so that you cross-env work globally.

npm install --global cross-env

Step 3:- Remove “cross-env”: “5.0.1” from the devDependencies section of the package.json file. You may actually skip this step and keep package.json. If you’d want.

Step 4:- Then run this command.

npm install --no-bin-links

Step 5:- After this finally you can run your main command

npm run dev

Tagged : / / / / / / /

Know about nodejs?

What is nodejs?

Node.js untangles concurrency by replacing the Java platform’s standard, multithreaded approach with single-threaded, event-driven I/O.

Node.js (Node) is an I/O environment built on top of Google Chrome’s JavaScript runtime — essentially, a server-side implementation of JavaScript. Node’s asynchronous, event-driven I/O model makes it easy for developers with JavaScript knowledge to build high-performing, scalable, and highly concurrent web applications rapidly and run them in the cloud.

Tagged : / / / /